[pypy-commit] pypy default: Next fix

arigo pypy.commits at gmail.com
Mon May 9 06:33:07 EDT 2016


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r84333:e61e2f4a32fa
Date: 2016-05-09 12:33 +0200
http://bitbucket.org/pypy/pypy/changeset/e61e2f4a32fa/

Log:	Next fix

diff --git a/pypy/module/cpyext/test/test_typeobject.py b/pypy/module/cpyext/test/test_typeobject.py
--- a/pypy/module/cpyext/test/test_typeobject.py
+++ b/pypy/module/cpyext/test/test_typeobject.py
@@ -1002,6 +1002,7 @@
         #
         class Bar(Foo):
             pass
+        assert Foo.__new__ is Bar.__new__
         Bar(); Bar()
         for i in range(10):
             if module.getCounter() >= 5050:
@@ -1021,4 +1022,4 @@
             if module.getCounter() >= 7070:
                 break
             self.debug_collect()
-        #assert module.getCounter() == 7070    -- oops, bug!
+        assert module.getCounter() == 7070
diff --git a/pypy/module/cpyext/typeobject.py b/pypy/module/cpyext/typeobject.py
--- a/pypy/module/cpyext/typeobject.py
+++ b/pypy/module/cpyext/typeobject.py
@@ -196,6 +196,10 @@
 
 def update_all_slots(space, w_type, pto):
     #  XXX fill slots in pto
+    # Not very sure about it, but according to
+    # test_call_tp_dealloc_when_created_from_python, we should not
+    # overwrite slots that are already set: these ones are probably
+    # coming from a parent C type.
 
     typedef = w_type.layout.typedef
     for method_name, slot_name, slot_names, slot_func in slotdefs_for_tp_slots:
@@ -223,7 +227,8 @@
         # XXX special case wrapper-functions and use a "specific" slot func
 
         if len(slot_names) == 1:
-            setattr(pto, slot_names[0], slot_func_helper)
+            if not getattr(pto, slot_names[0]):
+                setattr(pto, slot_names[0], slot_func_helper)
         else:
             assert len(slot_names) == 2
             struct = getattr(pto, slot_names[0])
@@ -240,7 +245,8 @@
                 struct = lltype.malloc(STRUCT_TYPE, flavor='raw', zero=True)
                 setattr(pto, slot_names[0], struct)
 
-            setattr(struct, slot_names[1], slot_func_helper)
+            if not getattr(struct, slot_names[1]):
+                setattr(struct, slot_names[1], slot_func_helper)
 
 def add_operators(space, dict_w, pto):
     # XXX support PyObject_HashNotImplemented


More information about the pypy-commit mailing list