inspect now raises OSError for objects without source file

CPython issue: https://bugs.python.org/issue44648
This commit is contained in:
Lumír 'Frenzy' Balhar authored and Lumir Balhar committed 2021-09-01 20:50:54 +02:00
1 parent 1d944943c3
commit eab1b8be8b
2 files changed
+22 -1

No files matched your search

+1 -1
View File
@@ -187,7 +187,7 @@ def _find_syntax_node_name(inference_state, python_object):
try:
python_object = _get_object_to_check(python_object)
path = inspect.getsourcefile(python_object)
except TypeError:
except (OSError, TypeError):
# The type might not be known (e.g. class_with_dict.__weakref__)
return None
path = None if path is None else Path(path)