diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2011-05-01 21:33:06 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2011-05-01 21:33:06 (GMT) |
commit | 6a534e7e7b9820bcae40883d6158ec19887fceb3 (patch) | |
tree | 258214af864165f89c10d4dbd3443d5cb9728788 /Lib/test/test_descr.py | |
parent | 571e8fda9b6fdf2172ee071457d5f9e73fe4d70d (diff) | |
parent | d9561318d849df12775d7a111aa85bbf62a54c0f (diff) | |
download | cpython-6a534e7e7b9820bcae40883d6158ec19887fceb3.zip cpython-6a534e7e7b9820bcae40883d6158ec19887fceb3.tar.gz cpython-6a534e7e7b9820bcae40883d6158ec19887fceb3.tar.bz2 |
(Merge 3.2) 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/test/test_descr.py')
-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 b0d531a..9273c46 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): |