diff options
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/inspect.py | 2 | ||||
-rw-r--r-- | Lib/test/test_inspect.py | 12 |
2 files changed, 13 insertions, 1 deletions
diff --git a/Lib/inspect.py b/Lib/inspect.py index 57d8c72..97e99aa 100644 --- a/Lib/inspect.py +++ b/Lib/inspect.py @@ -1092,7 +1092,7 @@ def getattr_static(obj, attr, default=_sentinel): instance_result = _sentinel if not isinstance(obj, type): instance_result = _check_instance(obj, attr) - klass = obj.__class__ + klass = type(obj) else: klass = obj diff --git a/Lib/test/test_inspect.py b/Lib/test/test_inspect.py index 88c57d3..e320c68 100644 --- a/Lib/test/test_inspect.py +++ b/Lib/test/test_inspect.py @@ -855,6 +855,18 @@ class TestGetattrStatic(unittest.TestCase): self.assertEqual(inspect.getattr_static(Thing, 'd'), meta.__dict__['d']) + def test_class_as_property(self): + class Base(object): + foo = 3 + + class Something(Base): + @property + def __class__(self): + return object + + self.assertEqual(inspect.getattr_static(Something(), 'foo'), 3) + self.assertEqual(inspect.getattr_static(Something, 'foo'), 3) + def test_main(): run_unittest( TestDecorators, TestRetrievingSourceCode, TestOneliners, TestBuggyCases, |