| 1692 | |
| 1693 | @functools.lru_cache() |
| 1694 | def _shadowed_dict_from_weakref_mro_tuple(*weakref_mro): |
| 1695 | for weakref_entry in weakref_mro: |
| 1696 | # Normally we'd have to check whether the result of weakref_entry() |
| 1697 | # is None here, in case the object the weakref is pointing to has died. |
| 1698 | # In this specific case, however, we know that the only caller of this |
| 1699 | # function is `_shadowed_dict()`, and that therefore this weakref is |
| 1700 | # guaranteed to point to an object that is still alive. |
| 1701 | entry = weakref_entry() |
| 1702 | dunder_dict = _get_dunder_dict_of_class(entry) |
| 1703 | if '__dict__' in dunder_dict: |
| 1704 | class_dict = dunder_dict['__dict__'] |
| 1705 | if not (type(class_dict) is types.GetSetDescriptorType and |
| 1706 | class_dict.__name__ == "__dict__" and |
| 1707 | class_dict.__objclass__ is entry): |
| 1708 | return class_dict |
| 1709 | return _sentinel |
| 1710 | |
| 1711 | |
| 1712 | def _shadowed_dict(klass): |