if Options.generate_cleanup_code:
# 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.put_goto(code.return_label)
def generate_module_cleanup_func(self, env, code):
if not Options.generate_cleanup_code:
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) {' %
Naming.cleanup_cname)
if Options.generate_cleanup_code >= 2:
/////////////// RegisterModuleCleanup ///////////////
//@substitute: naming
+//@requires: ModuleImport
static int __Pyx_RegisterCleanup(void) {
// Don't use Py_AtExit because that has a 32-call limit and is called