| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1787,11 +1787,8 @@ def _check_instance(obj, attr): | |||
| 1787 | 1787 | ||
| 1788 | 1788 | def _check_class(klass, attr): | |
| 1789 | 1789 | for entry in _static_getmro(klass): | |
| 1790 | - if _shadowed_dict(type(entry)) is _sentinel: | ||
| 1791 | - try: | ||
| 1792 | - return entry.__dict__[attr] | ||
| 1793 | - except KeyError: | ||
| 1794 | - pass | ||
| 1790 | + if _shadowed_dict(type(entry)) is _sentinel and attr in entry.__dict__: | ||
| 1791 | + return entry.__dict__[attr] | ||
| 1795 | 1792 | return _sentinel | |
| 1796 | 1793 | ||
| 1797 | 1794 | def _is_type(obj): | |
@@ -1803,11 +1800,9 @@ def _is_type(obj): | |||
| 1803 | 1800 | ||
| 1804 | 1801 | def _shadowed_dict(klass): | |
| 1805 | 1802 | for entry in _static_getmro(klass): | |
| 1806 | - try: | ||
| 1807 | - class_dict = _get_dunder_dict_of_class(entry)["__dict__"] | ||
| 1808 | - except KeyError: | ||
| 1809 | - pass | ||
| 1810 | - else: | ||
| 1803 | + dunder_dict = _get_dunder_dict_of_class(entry) | ||
| 1804 | + if '__dict__' in dunder_dict: | ||
| 1805 | + class_dict = dunder_dict['__dict__'] | ||
| 1811 | 1806 | if not (type(class_dict) is types.GetSetDescriptorType and | |
| 1812 | 1807 | class_dict.__name__ == "__dict__" and | |
| 1813 | 1808 | class_dict.__objclass__ is entry): | |
@@ -1850,11 +1845,11 @@ def getattr_static(obj, attr, default=_sentinel): | |||
| 1850 | 1845 | if obj is klass: | |
| 1851 | 1846 | # for types we check the metaclass too | |
| 1852 | 1847 | for entry in _static_getmro(type(klass)): | |
| 1853 | - if _shadowed_dict(type(entry)) is _sentinel: | ||
| 1854 | - try: | ||
| 1855 | - return entry.__dict__[attr] | ||
| 1856 | - except KeyError: | ||
| 1857 | - pass | ||
| 1848 | + if ( | ||
| 1849 | + _shadowed_dict(type(entry)) is _sentinel | ||
| 1850 | + and attr in entry.__dict__ | ||
| 1851 | + ): | ||
| 1852 | + return entry.__dict__[attr] | ||
| 1858 | 1853 | if default is not _sentinel: | |
| 1859 | 1854 | return default | |
| 1860 | 1855 | raise AttributeError(attr) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments