Commit c1dc048b authored by Stefan Behnel's avatar Stefan Behnel

Fix conditional code in __Pyx_PyType_Ready() for Py3.10.

parent 18fc9f76
...@@ -73,12 +73,12 @@ static int __Pyx_PyType_Ready(PyTypeObject *t) { ...@@ -73,12 +73,12 @@ static int __Pyx_PyType_Ready(PyTypeObject *t) {
// Make sure GC does not pick up our non-heap type as heap type with this hack! // Make sure GC does not pick up our non-heap type as heap type with this hack!
// For details, see https://github.com/cython/cython/issues/3603 // For details, see https://github.com/cython/cython/issues/3603
int gc_was_enabled; int gc_was_enabled;
#if PY_VERSION_HEX >= 0x030A00b1 #if PY_VERSION_HEX >= 0x030A00b1
// finally added in Py3.10 :) // finally added in Py3.10 :)
gc_was_enabled = PyGC_Disable(); gc_was_enabled = PyGC_Disable();
(void)__Pyx_PyObject_CallMethod0; (void)__Pyx_PyObject_CallMethod0;
#else #else
// Call gc.disable() as a backwards compatible fallback, but only if needed. // Call gc.disable() as a backwards compatible fallback, but only if needed.
PyObject *ret, *py_status; PyObject *ret, *py_status;
PyObject *gc = NULL; PyObject *gc = NULL;
...@@ -106,7 +106,7 @@ static int __Pyx_PyType_Ready(PyTypeObject *t) { ...@@ -106,7 +106,7 @@ static int __Pyx_PyType_Ready(PyTypeObject *t) {
Py_DECREF(gc); Py_DECREF(gc);
return -1; return -1;
} }
#endif #endif
// As of https://bugs.python.org/issue22079 // As of https://bugs.python.org/issue22079
// PyType_Ready enforces that all bases of a non-heap type are // PyType_Ready enforces that all bases of a non-heap type are
...@@ -126,10 +126,11 @@ static int __Pyx_PyType_Ready(PyTypeObject *t) { ...@@ -126,10 +126,11 @@ static int __Pyx_PyType_Ready(PyTypeObject *t) {
#if PY_VERSION_HEX >= 0x03050000 #if PY_VERSION_HEX >= 0x03050000
t->tp_flags &= ~Py_TPFLAGS_HEAPTYPE; t->tp_flags &= ~Py_TPFLAGS_HEAPTYPE;
if (gc_was_enabled) { #if PY_VERSION_HEX >= 0x030A00b1
#if PY_VERSION_HEX >= 0x030A00b1 if (gc_was_enabled)
PyGC_Enable(); PyGC_Enable();
#else #else
if (gc_was_enabled) {
PyObject *t, *v, *tb; PyObject *t, *v, *tb;
PyErr_Fetch(&t, &v, &tb); PyErr_Fetch(&t, &v, &tb);
ret = __Pyx_PyObject_CallMethod0(gc, PYUNICODE("enable")); ret = __Pyx_PyObject_CallMethod0(gc, PYUNICODE("enable"));
...@@ -146,7 +147,7 @@ static int __Pyx_PyType_Ready(PyTypeObject *t) { ...@@ -146,7 +147,7 @@ static int __Pyx_PyType_Ready(PyTypeObject *t) {
} }
} }
Py_DECREF(gc); Py_DECREF(gc);
#endif #endif
} }
#endif #endif
......
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