MCPcopy Index your code
hub / github.com/python/cpython / _shadowed_dict_from_weakref_mro_tuple

Function _shadowed_dict_from_weakref_mro_tuple

Lib/inspect.py:1718–1734  ·  view source on GitHub ↗
(*weakref_mro)

Source from the content-addressed store, hash-verified

1716
1717@functools.lru_cache()
1718def _shadowed_dict_from_weakref_mro_tuple(*weakref_mro):
1719 for weakref_entry in weakref_mro:
1720 # Normally we'd have to check whether the result of weakref_entry()
1721 # is None here, in case the object the weakref is pointing to has died.
1722 # In this specific case, however, we know that the only caller of this
1723 # function is `_shadowed_dict()`, and that therefore this weakref is
1724 # guaranteed to point to an object that is still alive.
1725 entry = weakref_entry()
1726 dunder_dict = _get_dunder_dict_of_class(entry)
1727 if '__dict__' in dunder_dict:
1728 class_dict = dunder_dict['__dict__']
1729 if not (type(class_dict) is types.GetSetDescriptorType and
1730 class_dict.__name__ == "__dict__" and
1731 (class_dict.__objclass__ is object or
1732 class_dict.__objclass__ is entry)):
1733 return class_dict
1734 return _sentinel
1735
1736
1737def _shadowed_dict(klass):

Callers 1

_shadowed_dictFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…