mirror of
https://github.com/python/cpython.git
synced 2025-10-08 08:01:55 +00:00
Metaclasses with metaclasses with a __dict__ descriptor can no longer trigger code execution with inspect.getattr_static.
Closes issue 11829.
This commit is contained in:
parent
65a3f4b8c5
commit
3ba95f8bd9
3 changed files with 25 additions and 4 deletions
|
@ -1161,10 +1161,11 @@ def getattr_static(obj, attr, default=_sentinel):
|
|||
if obj is klass:
|
||||
# for types we check the metaclass too
|
||||
for entry in _static_getmro(type(klass)):
|
||||
try:
|
||||
return entry.__dict__[attr]
|
||||
except KeyError:
|
||||
pass
|
||||
if _shadowed_dict(type(entry)) is _sentinel:
|
||||
try:
|
||||
return entry.__dict__[attr]
|
||||
except KeyError:
|
||||
pass
|
||||
if default is not _sentinel:
|
||||
return default
|
||||
raise AttributeError(attr)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue