Author: Armin Rigo <ar...@tunes.org>
Branch: cpyext-gc-support-2
Changeset: r81981:a3c663eba7c9
Date: 2016-01-27 19:21 +0100
http://bitbucket.org/pypy/pypy/changeset/a3c663eba7c9/

Log:    yay, test_api passes

diff --git a/pypy/module/cpyext/state.py b/pypy/module/cpyext/state.py
--- a/pypy/module/cpyext/state.py
+++ b/pypy/module/cpyext/state.py
@@ -80,12 +80,11 @@
 
         from pypy.module.cpyext.typeobject import setup_new_method_def
         from pypy.module.cpyext.api import INIT_FUNCTIONS
-        from pypy.module.cpyext.api import init_static_data_translated
 
         if we_are_translated():
             rawrefcount.init(llhelper(rawrefcount.RAWREFCOUNT_DEALLOC_TRIGGER,
                                       self.dealloc_trigger))
-            init_static_data_translated(space)
+            XXX#init_static_data_translated(space)
 
         setup_new_method_def(space)
 
diff --git a/pypy/module/cpyext/test/test_api.py 
b/pypy/module/cpyext/test/test_api.py
--- a/pypy/module/cpyext/test/test_api.py
+++ b/pypy/module/cpyext/test/test_api.py
@@ -53,7 +53,6 @@
         return state.clear_exception()
 
     def setup_method(self, func):
-        #return   # ZZZ
         freeze_refcnts(self)
 
     def teardown_method(self, func):
diff --git a/pypy/module/cpyext/test/test_cpyext.py 
b/pypy/module/cpyext/test/test_cpyext.py
--- a/pypy/module/cpyext/test/test_cpyext.py
+++ b/pypy/module/cpyext/test/test_cpyext.py
@@ -14,7 +14,7 @@
 from rpython.tool.udir import udir
 from pypy.module.cpyext import api
 from pypy.module.cpyext.state import State
-from pypy.module.cpyext.pyobject import RefcountState
+from pypy.module.cpyext.pyobject import debug_collect
 from pypy.module.cpyext.pyobject import Py_DecRef, InvalidPointerException
 from rpython.tool.identity_dict import identity_dict
 from rpython.tool import leakfinder
@@ -92,6 +92,7 @@
     return str(pydname)
 
 def freeze_refcnts(self):
+    return #ZZZ
     state = self.space.fromcache(RefcountState)
     self.frozen_refcounts = {}
     for w_obj, obj in state.py_objects_w2r.iteritems():
@@ -109,6 +110,7 @@
 
     @staticmethod
     def cleanup_references(space):
+        return #ZZZ
         state = space.fromcache(RefcountState)
 
         import gc; gc.collect()
@@ -127,6 +129,8 @@
         state.reset_borrowed_references()
 
     def check_and_print_leaks(self):
+        debug_collect()
+        return #ZZZ
         # check for sane refcnts
         import gc
 
@@ -212,8 +216,8 @@
         cls.space.getbuiltinmodule("cpyext")
         from pypy.module.imp.importing import importhook
         importhook(cls.space, "os") # warm up reference counts
-        state = cls.space.fromcache(RefcountState)
-        state.non_heaptypes_w[:] = []
+        #state = cls.space.fromcache(RefcountState) ZZZ
+        #state.non_heaptypes_w[:] = []
 
     def setup_method(self, func):
         @unwrap_spec(name=str)
@@ -348,7 +352,7 @@
             interp2app(record_imported_module))
         self.w_here = self.space.wrap(
             str(py.path.local(pypydir)) + '/module/cpyext/test/')
-
+        self.w_debug_collect = self.space.wrap(interp2app(debug_collect))
 
         # create the file lock before we count allocations
         self.space.call_method(self.space.sys.get("stdout"), "flush")
@@ -647,7 +651,7 @@
             Py_DECREF(true_obj);
             Py_DECREF(true_obj);
             fprintf(stderr, "REFCNT %i %i\\n", refcnt, refcnt_after);
-            return PyBool_FromLong(refcnt_after == refcnt+2 && refcnt < 3);
+            return PyBool_FromLong(refcnt_after == refcnt + 2);
         }
         static PyObject* foo_bar(PyObject* self, PyObject *args)
         {
@@ -662,8 +666,10 @@
                 return NULL;
             refcnt_after = true_obj->ob_refcnt;
             Py_DECREF(tup);
-            fprintf(stderr, "REFCNT2 %i %i\\n", refcnt, refcnt_after);
-            return PyBool_FromLong(refcnt_after == refcnt);
+            fprintf(stderr, "REFCNT2 %i %i %i\\n", refcnt, refcnt_after,
+                    true_obj->ob_refcnt);
+            return PyBool_FromLong(refcnt_after == refcnt + 1 &&
+                                   refcnt == true_obj->ob_refcnt);
         }
 
         static PyMethodDef methods[] = {
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
@@ -568,9 +568,6 @@
 
     finish_type_2(space, py_type, w_obj)
 
-    state = space.fromcache(RefcountState)
-    state.non_heaptypes_w.append(w_obj)
-
     return w_obj
 
 def finish_type_1(space, pto):
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to