From bdd8930e8f4130db160cc816a3e29c29a2ce1cdd Mon Sep 17 00:00:00 2001 From: Eldar Abusalimov Date: Sat, 25 Oct 2014 23:02:56 +0400 Subject: [PATCH 14/15] (test) (crasher) attr lookup on super with uninitialized type Attribute lookup on a super object costructed with a type which has type->tp_mro == NULL leads to a segfault. --- Lib/test/test_mro.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Lib/test/test_mro.py b/Lib/test/test_mro.py index 732d705..d76d195 100644 --- a/Lib/test/test_mro.py +++ b/Lib/test/test_mro.py @@ -214,6 +214,22 @@ class MroTest(unittest.TestCase): class A(metaclass=M): pass + def test_incomplete_super(self): + """ + Attrubute lookup on a super object must be aware that + its target type can be uninitialized (type->tp_mro == NULL). + """ + class M(DebugHelperMeta): + def mro(cls): + if cls.__mro__ is None: + with self.assertRaises(AttributeError): + super(cls, cls).xxx + + return type.mro(cls) + + class A(metaclass=M): + pass + if __name__ == '__main__': unittest.main() -- 2.1.1