summaryrefslogtreecommitdiff
path: root/Cython/Utility/ModuleSetupCode.c
diff options
context:
space:
mode:
authorStefan Behnel <stefan_ml@behnel.de>2012-08-25 22:18:34 +0200
committerStefan Behnel <stefan_ml@behnel.de>2012-08-25 22:18:34 +0200
commitad5f8e66c2cce34ace617aff01be16ec2c0a5cb2 (patch)
treec232b39cba50556ee6d76bbdf960aeeaac9d9838 /Cython/Utility/ModuleSetupCode.c
parentd3ddbddb80df05b702e5d43b73def4163c959e7f (diff)
downloadcython-ad5f8e66c2cce34ace617aff01be16ec2c0a5cb2.tar.gz
use proper module.m_free() way to run module cleanup code in Py3, way after running atexit functions etc.
Diffstat (limited to 'Cython/Utility/ModuleSetupCode.c')
-rw-r--r--Cython/Utility/ModuleSetupCode.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/Cython/Utility/ModuleSetupCode.c b/Cython/Utility/ModuleSetupCode.c
index c3f4d5608..4d566292c 100644
--- a/Cython/Utility/ModuleSetupCode.c
+++ b/Cython/Utility/ModuleSetupCode.c
@@ -573,13 +573,16 @@ end:
/////////////// RegisterModuleCleanup.proto ///////////////
//@substitute: naming
+#if PY_MAJOR_VERSION < 3
static int __Pyx_RegisterCleanup(void); /*proto*/
-static PyObject* ${cleanup_cname}(CYTHON_UNUSED PyObject *self, CYTHON_UNUSED PyObject *unused); /*proto*/
+static PyObject* ${cleanup_cname}(PyObject *self, PyObject *unused); /*proto*/
+#endif
/////////////// RegisterModuleCleanup ///////////////
//@substitute: naming
//@requires: ModuleImport
+#if PY_MAJOR_VERSION < 3
static int __Pyx_RegisterCleanup(void) {
// Don't use Py_AtExit because that has a 32-call limit and is called
// after python finalization.
@@ -604,7 +607,6 @@ static int __Pyx_RegisterCleanup(void) {
atexit = __Pyx_ImportModule("atexit");
if (!atexit)
goto bad;
-#if PY_MAJOR_VERSION < 3
reg = __Pyx_GetAttrString(atexit, "_exithandlers");
if (reg && PyList_Check(reg)) {
PyObject *a, *kw;
@@ -622,7 +624,6 @@ static int __Pyx_RegisterCleanup(void) {
goto bad;
ret = PyList_Insert(reg, 0, args);
} else
-#endif
{
if (!reg)
PyErr_Clear();
@@ -646,3 +647,4 @@ bad:
Py_XDECREF(res);
return ret;
}
+#endif