diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2011-05-01 21:19:15 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2011-05-01 21:19:15 (GMT) |
commit | 3249dec02484674830177488c8f01d8d04873928 (patch) | |
tree | 6e41437d0f5066601875d2219f714367978ed178 /Lib | |
parent | 9c4f09d0f487de32444ebc2e11fdbaadf3dc5cd3 (diff) | |
download | cpython-3249dec02484674830177488c8f01d8d04873928.zip cpython-3249dec02484674830177488c8f01d8d04873928.tar.gz cpython-3249dec02484674830177488c8f01d8d04873928.tar.bz2 |
Issue #9756: When calling a method descriptor or a slot wrapper descriptor, the
check of the object type doesn't read the __class__ attribute anymore. Fix a
crash if a class override its __class__ attribute (e.g. a proxy of the str
type).
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_descr.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py index bd88f45..aafe428 100644 --- a/Lib/test/test_descr.py +++ b/Lib/test/test_descr.py @@ -4235,6 +4235,22 @@ order (MRO) for bases """ with self.assertRaises(AttributeError): del X.__abstractmethods__ + def test_proxy_call(self): + class FakeStr: + __class__ = str + + fake_str = FakeStr() + # isinstance() reads __class__ + self.assertTrue(isinstance(fake_str, str)) + + # call a method descriptor + with self.assertRaises(TypeError): + str.split(fake_str) + + # call a slot wrapper descriptor + with self.assertRaises(TypeError): + str.__add__(fake_str, "abc") + class DictProxyTests(unittest.TestCase): def setUp(self): |