Skip to content

Commit 6cea9bd

Browse files
committed
move cdef
1 parent 6773a64 commit 6cea9bd

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -196,22 +196,24 @@ cdef class SSLChannelCredentials(ChannelCredentials):
196196
self._certificate_chain = certificate_chain
197197

198198
cdef grpc_channel_credentials *c(self) except *:
199-
cdef const char *c_pem_root_certificates = NULL
199+
cdef const char *c_pem_root_certificates
200+
cdef const char *c_private_key
201+
cdef const char *c_cert_chain
200202
cdef grpc_tls_credenentials_options* c_tls_credentials_options
201203
cdef grpc_tls_identity_pairs* c_tls_identity_pairs = NULL
204+
cdef grpc_tls_certificate_provider* c_tls_certificate_provider
202205

203206
c_tls_credentials_options = grpc_tls_credenentials_options_create()
204-
if self._pem_root_certificates:
207+
if self._pem_root_certificates is not None:
205208
c_pem_root_certificates = self._pem_root_certificates
209+
else:
210+
c_pem_root_certificates = NULL
206211
if self._private_key or self._certificate_chain:
207212
c_tls_identity_pairs = grpc_tls_identity_pairs_create()
208-
cdef const char *c_private_key
209213
c_private_key = self._private_key if self._private_key else NULL
210-
cdef const char *c_cert_chain
211214
c_cert_chain = self._certificate_chain if self._certificate_chain else NULL
212215
grpc_tls_identity_pairs_add_pair(c_tls_identity_pairs, c_private_key, c_cert_chain)
213216
if c_pem_root_certificates != NULL or c_tls_identity_pairs != NULL:
214-
cdef grpc_tls_certificate_provider* c_tls_certificate_provider
215217
c_tls_certificate_provider = grpc_tls_certificate_provider_static_data_create(c_pem_root_certificates, c_tls_identity_pairs)
216218
grpc_tls_credentials_options_set_certificate_provider(c_tls_credentials_options, c_tls_certificate_provider)
217219
with nogil:

0 commit comments

Comments
 (0)