Issue 9732: __class__ no longer checked on objects by getattr_static

This commit is contained in:
Michael Foord 2010-11-20 16:58:30 +00:00
parent e516265bbc
commit 35184edd3d
2 changed files with 13 additions and 2 deletions

View file

@ -1080,6 +1080,13 @@ def _check_class(klass, attr):
pass
return _sentinel
def _is_type(obj):
try:
_static_getmro(obj)
except TypeError:
return False
return True
def getattr_static(obj, attr, default=_sentinel):
"""Retrieve attributes without triggering dynamic lookup via the
@ -1093,7 +1100,7 @@ def getattr_static(obj, attr, default=_sentinel):
documentation for details.
"""
instance_result = _sentinel
if not isinstance(obj, type):
if not _is_type(obj):
instance_result = _check_instance(obj, attr)
klass = type(obj)
else: