mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Merge
This commit is contained in:
commit
85530aa1c3
3 changed files with 25 additions and 4 deletions
|
@ -1186,6 +1186,7 @@ def getattr_static(obj, attr, default=_sentinel):
|
||||||
if obj is klass:
|
if obj is klass:
|
||||||
# for types we check the metaclass too
|
# for types we check the metaclass too
|
||||||
for entry in _static_getmro(type(klass)):
|
for entry in _static_getmro(type(klass)):
|
||||||
|
if _shadowed_dict(type(entry)) is _sentinel:
|
||||||
try:
|
try:
|
||||||
return entry.__dict__[attr]
|
return entry.__dict__[attr]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
|
|
|
@ -1088,6 +1088,23 @@ class TestGetattrStatic(unittest.TestCase):
|
||||||
self.assertIsNot(inspect.getattr_static(sys, "version", sentinel),
|
self.assertIsNot(inspect.getattr_static(sys, "version", sentinel),
|
||||||
sentinel)
|
sentinel)
|
||||||
|
|
||||||
|
def test_metaclass_with_metaclass_with_dict_as_property(self):
|
||||||
|
class MetaMeta(type):
|
||||||
|
@property
|
||||||
|
def __dict__(self):
|
||||||
|
self.executed = True
|
||||||
|
return dict(spam=42)
|
||||||
|
|
||||||
|
class Meta(type, metaclass=MetaMeta):
|
||||||
|
executed = False
|
||||||
|
|
||||||
|
class Thing(metaclass=Meta):
|
||||||
|
pass
|
||||||
|
|
||||||
|
with self.assertRaises(AttributeError):
|
||||||
|
inspect.getattr_static(Thing, "spam")
|
||||||
|
self.assertFalse(Thing.executed)
|
||||||
|
|
||||||
class TestGetGeneratorState(unittest.TestCase):
|
class TestGetGeneratorState(unittest.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
|
|
@ -422,6 +422,9 @@ Library
|
||||||
- Issue #13620: Support for Chrome browser in webbrowser.py Patch contributed
|
- Issue #13620: Support for Chrome browser in webbrowser.py Patch contributed
|
||||||
by Arnaud Calmettes.
|
by Arnaud Calmettes.
|
||||||
|
|
||||||
|
- Issue #11829: Fix code execution holes in inspect.getattr_static for
|
||||||
|
metaclasses with metaclasses. Patch by Andreas Stührk.
|
||||||
|
|
||||||
- Issue #12708: Add starmap() and starmap_async() methods (similar to
|
- Issue #12708: Add starmap() and starmap_async() methods (similar to
|
||||||
itertools.starmap()) to multiprocessing.Pool. Patch by Hynek Schlawack.
|
itertools.starmap()) to multiprocessing.Pool. Patch by Hynek Schlawack.
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue