Commit d3ddbddb authored by Stefan Behnel's avatar Stefan Behnel

clean up injection of RegisterModuleCleanup utility code

parent ae33c0ec
...@@ -1913,7 +1913,8 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -1913,7 +1913,8 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
if Options.generate_cleanup_code: if Options.generate_cleanup_code:
# this should be replaced by the module's tp_clear in Py3 # this should be replaced by the module's tp_clear in Py3
env.use_utility_code(import_module_utility_code) code.globalstate.use_utility_code(
UtilityCode.load_cached("RegisterModuleCleanup", "ModuleSetupCode.c"))
code.putln("if (__Pyx_RegisterCleanup()) %s;" % code.error_goto(self.pos)) code.putln("if (__Pyx_RegisterCleanup()) %s;" % code.error_goto(self.pos))
code.put_goto(code.return_label) code.put_goto(code.return_label)
...@@ -1974,8 +1975,6 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -1974,8 +1975,6 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
def generate_module_cleanup_func(self, env, code): def generate_module_cleanup_func(self, env, code):
if not Options.generate_cleanup_code: if not Options.generate_cleanup_code:
return return
code.globalstate.use_utility_code(
UtilityCode.load_cached("RegisterModuleCleanup", "ModuleSetupCode.c"))
code.putln('static PyObject *%s(CYTHON_UNUSED PyObject *self, CYTHON_UNUSED PyObject *unused) {' % code.putln('static PyObject *%s(CYTHON_UNUSED PyObject *self, CYTHON_UNUSED PyObject *unused) {' %
Naming.cleanup_cname) Naming.cleanup_cname)
if Options.generate_cleanup_code >= 2: if Options.generate_cleanup_code >= 2:
......
...@@ -578,6 +578,7 @@ static PyObject* ${cleanup_cname}(CYTHON_UNUSED PyObject *self, CYTHON_UNUSED Py ...@@ -578,6 +578,7 @@ static PyObject* ${cleanup_cname}(CYTHON_UNUSED PyObject *self, CYTHON_UNUSED Py
/////////////// RegisterModuleCleanup /////////////// /////////////// RegisterModuleCleanup ///////////////
//@substitute: naming //@substitute: naming
//@requires: ModuleImport
static int __Pyx_RegisterCleanup(void) { static int __Pyx_RegisterCleanup(void) {
// Don't use Py_AtExit because that has a 32-call limit and is called // Don't use Py_AtExit because that has a 32-call limit and is called
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment