[pypy-commit] pypy py3.5: Don't segfault in test_typeobject.py::test_incomplete_extend_3()

rlamy pypy.commits at gmail.com
Tue Oct 3 05:35:18 EDT 2017


Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: py3.5
Changeset: r92564:f9ce0cdc4b97
Date: 2017-10-03 11:34 +0200
http://bitbucket.org/pypy/pypy/changeset/f9ce0cdc4b97/

Log:	Don't segfault in test_typeobject.py::test_incomplete_extend_3()

diff --git a/pypy/objspace/std/typeobject.py b/pypy/objspace/std/typeobject.py
--- a/pypy/objspace/std/typeobject.py
+++ b/pypy/objspace/std/typeobject.py
@@ -151,7 +151,7 @@
                           'hasuserdel',
                           'weakrefable',
                           'hasdict',
-                          'layout',
+                          'layout?',
                           'terminator',
                           '_version_tag?',
                           'name?',
@@ -191,6 +191,7 @@
         self.flag_sequence_bug_compat = False
         self.flag_map_or_seq = '?'   # '?' means "don't know, check otherwise"
 
+        self.layout = None  # the lines below may try to access self.layout
         if overridetypedef is not None:
             assert not force_new_layout
             layout = setup_builtin_type(self, overridetypedef)
@@ -493,6 +494,10 @@
         if not isinstance(w_subtype, W_TypeObject):
             raise oefmt(space.w_TypeError,
                         "X is not a type object ('%T')", w_subtype)
+        if not w_subtype.layout:
+            raise oefmt(space.w_TypeError,
+                "%N.__new__(%N): uninitialized type %N may not be instantiated yet.",
+                self, w_subtype, w_subtype)
         if not w_subtype.issubtype(self):
             raise oefmt(space.w_TypeError,
                         "%N.__new__(%N): %N is not a subtype of %N",


More information about the pypy-commit mailing list