Commit 8541d7be authored by Stefan Behnel's avatar Stefan Behnel

fix crash bug during final cleanup for cimported base types

parent dfb2d745
...@@ -11,6 +11,8 @@ Features added ...@@ -11,6 +11,8 @@ Features added
Bugs fixed Bugs fixed
---------- ----------
* During final interpreter cleanup (with types cleanup enabled at compile time), extension types that inherit from base types over more than one level that were cimported from other modules could lead to a crash.
* In CPython 3.3, converting a Unicode character to the Py_UNICODE type could fail to raise an overflow for non-BMP characters that do not fit into a wchar_t on the current platform. * In CPython 3.3, converting a Unicode character to the Py_UNICODE type could fail to raise an overflow for non-BMP characters that do not fit into a wchar_t on the current platform.
* Negative C integer constants lost their longness suffix in the generated C code. * Negative C integer constants lost their longness suffix in the generated C code.
......
...@@ -7,10 +7,13 @@ static void __Pyx_call_next_tp_dealloc(PyObject* obj, destructor current_tp_deal ...@@ -7,10 +7,13 @@ static void __Pyx_call_next_tp_dealloc(PyObject* obj, destructor current_tp_deal
static void __Pyx_call_next_tp_dealloc(PyObject* obj, destructor current_tp_dealloc) { static void __Pyx_call_next_tp_dealloc(PyObject* obj, destructor current_tp_dealloc) {
PyTypeObject* type = Py_TYPE(obj); PyTypeObject* type = Py_TYPE(obj);
/* try to find the first parent type that has a different tp_dealloc() function */
while (type && type->tp_dealloc != current_tp_dealloc) while (type && type->tp_dealloc != current_tp_dealloc)
type = type->tp_base; type = type->tp_base;
if (type && type->tp_base) while (type && type->tp_dealloc == current_tp_dealloc)
type->tp_base->tp_dealloc(obj); type = type->tp_base;
if (type)
type->tp_dealloc(obj);
} }
/////////////// CallNextTpTraverse.proto /////////////// /////////////// CallNextTpTraverse.proto ///////////////
...@@ -21,10 +24,13 @@ static int __Pyx_call_next_tp_traverse(PyObject* obj, visitproc v, void *a, trav ...@@ -21,10 +24,13 @@ static int __Pyx_call_next_tp_traverse(PyObject* obj, visitproc v, void *a, trav
static int __Pyx_call_next_tp_traverse(PyObject* obj, visitproc v, void *a, traverseproc current_tp_traverse) { static int __Pyx_call_next_tp_traverse(PyObject* obj, visitproc v, void *a, traverseproc current_tp_traverse) {
PyTypeObject* type = Py_TYPE(obj); PyTypeObject* type = Py_TYPE(obj);
/* try to find the first parent type that has a different tp_traverse() function */
while (type && type->tp_traverse != current_tp_traverse) while (type && type->tp_traverse != current_tp_traverse)
type = type->tp_base; type = type->tp_base;
if (type && type->tp_base && type->tp_base->tp_traverse) while (type && type->tp_traverse == current_tp_traverse)
return type->tp_base->tp_traverse(obj, v, a); type = type->tp_base;
if (type && type->tp_traverse)
return type->tp_traverse(obj, v, a);
// FIXME: really ignore? // FIXME: really ignore?
return 0; return 0;
} }
...@@ -37,8 +43,11 @@ static void __Pyx_call_next_tp_clear(PyObject* obj, inquiry current_tp_dealloc); ...@@ -37,8 +43,11 @@ static void __Pyx_call_next_tp_clear(PyObject* obj, inquiry current_tp_dealloc);
static void __Pyx_call_next_tp_clear(PyObject* obj, inquiry current_tp_clear) { static void __Pyx_call_next_tp_clear(PyObject* obj, inquiry current_tp_clear) {
PyTypeObject* type = Py_TYPE(obj); PyTypeObject* type = Py_TYPE(obj);
/* try to find the first parent type that has a different tp_clear() function */
while (type && type->tp_clear != current_tp_clear) while (type && type->tp_clear != current_tp_clear)
type = type->tp_base; type = type->tp_base;
if (type && type->tp_base && type->tp_base->tp_clear) while (type && type->tp_clear == current_tp_clear)
type->tp_base->tp_clear(obj); type = type->tp_base;
if (type && type->tp_clear)
type->tp_clear(obj);
} }
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