@@ -149,6 +149,16 @@ def safe_module_name(n):
149
149
return '_mod_' + n .replace ('.' , '_' )
150
150
return n
151
151
152
+ def do_not_inspect (v ):
153
+ # https://github.com/Microsoft/python-language-server/issues/740
154
+ # https://github.com/cython/cython/issues/1470
155
+ if type (v ).__name__ != "fused_cython_function" :
156
+ return False
157
+
158
+ # If a fused function has __defaults__, then attempting to access
159
+ # __kwdefaults__ will fail if generated before cython 0.29.6.
160
+ return bool (getattr (v , "__defaults__" , False ))
161
+
152
162
class Signature (object ):
153
163
# These two dictionaries start with Python 3 values.
154
164
# There is an update below for Python 2 differences.
@@ -330,6 +340,9 @@ def __str__(self):
330
340
return self .fullsig
331
341
332
342
def _init_argspec_fromsignature (self , defaults ):
343
+ if do_not_inspect (self .callable ):
344
+ return
345
+
333
346
try :
334
347
sig = inspect .signature (self .callable )
335
348
except Exception :
@@ -351,6 +364,9 @@ def _init_argspec_fromsignature(self, defaults):
351
364
return self .name + str (sig )
352
365
353
366
def _init_restype_fromsignature (self ):
367
+ if do_not_inspect (self .callable ):
368
+ return
369
+
354
370
try :
355
371
sig = inspect .signature (self .callable )
356
372
except Exception :
@@ -366,6 +382,9 @@ def _init_restype_fromsignature(self):
366
382
return 'return ' + ann
367
383
368
384
def _init_argspec_fromargspec (self , defaults ):
385
+ if do_not_inspect (self .callable ):
386
+ return
387
+
369
388
try :
370
389
args = (getattr (inspect , 'getfullargspec' , None ) or inspect .getargspec )(self .callable )
371
390
except Exception :
0 commit comments