Skip to content

Commit 1dc1cd0

Browse files
committed
bpo-38026: fix inspect.getattr_static
It should avoid dynamic lookup including `isinstance`. This is regression caused by pythonGH-5351.
1 parent 675d17c commit 1dc1cd0

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Lib/inspect.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1558,7 +1558,7 @@ def _shadowed_dict(klass):
15581558
except KeyError:
15591559
pass
15601560
else:
1561-
if not (isinstance(class_dict, types.GetSetDescriptorType) and
1561+
if not (type(class_dict) is types.GetSetDescriptorType and
15621562
class_dict.__name__ == "__dict__" and
15631563
class_dict.__objclass__ is entry):
15641564
return class_dict
@@ -1580,7 +1580,7 @@ def getattr_static(obj, attr, default=_sentinel):
15801580
klass = type(obj)
15811581
dict_attr = _shadowed_dict(klass)
15821582
if (dict_attr is _sentinel or
1583-
isinstance(dict_attr, types.MemberDescriptorType)):
1583+
type(dict_attr) is types.MemberDescriptorType):
15841584
instance_result = _check_instance(obj, attr)
15851585
else:
15861586
klass = obj

0 commit comments

Comments
 (0)