Skip to content

Commit

Permalink
BUG: add support for inspecting built-in modules
Browse files Browse the repository at this point in the history
  • Loading branch information
neutrinoceros committed May 16, 2024
1 parent 8efd0f7 commit 9135fd3
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/wxc/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,15 @@ def get_full_data(name: str) -> dict:
source = get_sourcefile(obj)
except RecursionError:
pass
except TypeError:
# as of Python 3.11, inspect.getfile doesn't have support for properties
# but we're not making this a hard failure in case it is added in the future
# and we fallback to finding out the sourcefile of the class itself
if isinstance(obj, property):
except TypeError as exc:
if "built-in module" in str(exc):
# see https://github.com/neutrinoceros/wxc/issues/233
data["source"] = "built-in"
break
elif isinstance(obj, property):
# as of Python 3.11, inspect.getfile doesn't have support for properties
# but we're not making this a hard failure in case it is added in the future
# and we fallback to finding out the sourcefile of the class itself
continue
else:
raise
Expand Down

0 comments on commit 9135fd3

Please sign in to comment.