summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_inspect.py
diff options
context:
space:
mode:
authorMichael Foord <michael@voidspace.org.uk>2011-12-22 01:13:37 (GMT)
committerMichael Foord <michael@voidspace.org.uk>2011-12-22 01:13:37 (GMT)
commit3ba95f8bd984a0033c0b2da9974f67f537dedc9e (patch)
treeea10caf6115d029111ef9413fbb1e943df8546c7 /Lib/test/test_inspect.py
parent65a3f4b8c57a761cfe0e6ee14565db421c50f4c0 (diff)
downloadcpython-3ba95f8bd984a0033c0b2da9974f67f537dedc9e.zip
cpython-3ba95f8bd984a0033c0b2da9974f67f537dedc9e.tar.gz
cpython-3ba95f8bd984a0033c0b2da9974f67f537dedc9e.tar.bz2
Metaclasses with metaclasses with a __dict__ descriptor can no longer trigger code execution with inspect.getattr_static.
Closes issue 11829.
Diffstat (limited to 'Lib/test/test_inspect.py')
-rw-r--r--Lib/test/test_inspect.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/test/test_inspect.py b/Lib/test/test_inspect.py
index 56f9929..fad4d5a 100644
--- a/Lib/test/test_inspect.py
+++ b/Lib/test/test_inspect.py
@@ -1088,6 +1088,23 @@ class TestGetattrStatic(unittest.TestCase):
self.assertIsNot(inspect.getattr_static(sys, "version", 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):
def setUp(self):