[pypy-commit] pypy cpyext-cleanup: Put deallocation trigger initialisation all in one place

rlamy pypy.commits at gmail.com
Thu Jan 5 08:08:45 EST 2017


Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: cpyext-cleanup
Changeset: r89375:64f7a07e347f
Date: 2017-01-05 13:08 +0000
http://bitbucket.org/pypy/pypy/changeset/64f7a07e347f/

Log:	Put deallocation trigger initialisation all in one place

diff --git a/pypy/module/cpyext/__init__.py b/pypy/module/cpyext/__init__.py
--- a/pypy/module/cpyext/__init__.py
+++ b/pypy/module/cpyext/__init__.py
@@ -1,5 +1,4 @@
 from pypy.interpreter.mixedmodule import MixedModule
-from pypy.interpreter import gateway
 from pypy.module.cpyext.state import State
 from pypy.module.cpyext import api
 
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
@@ -2,7 +2,6 @@
 from rpython.rtyper.lltypesystem import rffi, lltype
 from pypy.interpreter.error import OperationError, oefmt
 from pypy.interpreter import executioncontext
-from rpython.rtyper.lltypesystem import lltype
 from rpython.rtyper.annlowlevel import llhelper
 from rpython.rlib.rdynload import DLLHANDLE
 from rpython.rlib import rawrefcount
@@ -15,9 +14,6 @@
         self.programname = lltype.nullptr(rffi.CCHARP.TO)
         self.version = lltype.nullptr(rffi.CCHARP.TO)
         self.builder = None
-        if space.config.translation.gc != "boehm":
-            pyobj_dealloc_action = PyObjDeallocAction(space)
-            self.dealloc_trigger = lambda: pyobj_dealloc_action.fire()
 
     def reset(self):
         from pypy.module.cpyext.modsupport import PyMethodDef
@@ -74,6 +70,12 @@
                 action = BoehmPyObjDeallocAction(self.space)
                 self.space.actionflag.register_periodic_action(action,
                     use_bytecode_counter=True)
+            else:
+                pyobj_dealloc_action = PyObjDeallocAction(space)
+                self.dealloc_trigger = lambda: pyobj_dealloc_action.fire()
+                rawrefcount.init(
+                    llhelper(rawrefcount.RAWREFCOUNT_DEALLOC_TRIGGER,
+                    self.dealloc_trigger))
 
     def install_dll(self, eci):
         """NOT_RPYTHON
@@ -89,10 +91,6 @@
         from pypy.module.cpyext.api import INIT_FUNCTIONS
 
         if we_are_translated():
-            if space.config.translation.gc != "boehm":
-                rawrefcount.init(
-                    llhelper(rawrefcount.RAWREFCOUNT_DEALLOC_TRIGGER,
-                    self.dealloc_trigger))
             self.builder.attach_all(space)
 
         setup_new_method_def(space)


More information about the pypy-commit mailing list