Skip to content
This repository was archived by the owner on Apr 14, 2022. It is now read-only.

Skip bad fused cython functions during scrape #995

Merged
merged 1 commit into from
Apr 22, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/Analysis/Ast/Impl/scrape_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,16 @@ def safe_module_name(n):
return '_mod_' + n.replace('.', '_')
return n

def do_not_inspect(v):
# https://github.com/Microsoft/python-language-server/issues/740
# https://github.com/cython/cython/issues/1470
if type(v).__name__ != "fused_cython_function":
return False

# If a fused function has __defaults__, then attempting to access
# __kwdefaults__ will fail if generated before cython 0.29.6.
return bool(getattr(v, "__defaults__", False))

class Signature(object):
# These two dictionaries start with Python 3 values.
# There is an update below for Python 2 differences.
Expand Down Expand Up @@ -330,6 +340,9 @@ def __str__(self):
return self.fullsig

def _init_argspec_fromsignature(self, defaults):
if do_not_inspect(self.callable):
return

try:
sig = inspect.signature(self.callable)
except Exception:
Expand All @@ -351,6 +364,9 @@ def _init_argspec_fromsignature(self, defaults):
return self.name + str(sig)

def _init_restype_fromsignature(self):
if do_not_inspect(self.callable):
return

try:
sig = inspect.signature(self.callable)
except Exception:
Expand All @@ -366,6 +382,9 @@ def _init_restype_fromsignature(self):
return 'return ' + ann

def _init_argspec_fromargspec(self, defaults):
if do_not_inspect(self.callable):
return

try:
args = (getattr(inspect, 'getfullargspec', None) or inspect.getargspec)(self.callable)
except Exception:
Expand Down