summaryrefslogtreecommitdiff
path: root/Cython/Utility/ModuleSetupCode.c
diff options
context:
space:
mode:
authorStefan Behnel <stefan_ml@behnel.de>2012-08-25 21:34:10 +0200
committerStefan Behnel <stefan_ml@behnel.de>2012-08-25 21:34:10 +0200
commitae33c0ec3cb98417204b4902d865fb28e7500e7a (patch)
tree2fb155deece7bb1216bd38b95af99bf1c75a47d1 /Cython/Utility/ModuleSetupCode.c
parent3c833d65a18e9b23bea78e7544e8594e1053f6c9 (diff)
downloadcython-ae33c0ec3cb98417204b4902d865fb28e7500e7a.tar.gz
atexit._exithandlers is no longer available in Py3
Diffstat (limited to 'Cython/Utility/ModuleSetupCode.c')
-rw-r--r--Cython/Utility/ModuleSetupCode.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/Cython/Utility/ModuleSetupCode.c b/Cython/Utility/ModuleSetupCode.c
index 9d8962b0b..eb51acb86 100644
--- a/Cython/Utility/ModuleSetupCode.c
+++ b/Cython/Utility/ModuleSetupCode.c
@@ -583,7 +583,7 @@ static int __Pyx_RegisterCleanup(void) {
// Don't use Py_AtExit because that has a 32-call limit and is called
// after python finalization.
// Also, we try to prepend the cleanup function to "atexit._exithandlers"
- // because CPython runs them last-to-first. Being run last allows
+ // in Py2 because CPython runs them last-to-first. Being run last allows
// user exit code to run before us that may depend on the globals
// and cached objects that we are about to clean up.
@@ -603,6 +603,7 @@ 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;
@@ -619,7 +620,9 @@ static int __Pyx_RegisterCleanup(void) {
if (!args)
goto bad;
ret = PyList_Insert(reg, 0, args);
- } else {
+ } else
+#endif
+ {
if (!reg)
PyErr_Clear();
Py_XDECREF(reg);