Commit 3260ece5 authored by Stefan Behnel's avatar Stefan Behnel

fix memory leak in new exception raising code

parent 4d8b1675
...@@ -5061,7 +5061,6 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) { ...@@ -5061,7 +5061,6 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) {
} }
value = type; value = type;
type = (PyObject*) Py_TYPE(value); type = (PyObject*) Py_TYPE(value);
Py_INCREF(type);
} else if (!PyExceptionClass_Check(type)) { } else if (!PyExceptionClass_Check(type)) {
PyErr_SetString(PyExc_TypeError, PyErr_SetString(PyExc_TypeError,
"raise: exception class must be a subclass of BaseException"); "raise: exception class must be a subclass of BaseException");
...@@ -5072,19 +5071,18 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) { ...@@ -5072,19 +5071,18 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) {
if (tb) { if (tb) {
PyThreadState *tstate = PyThreadState_GET(); PyThreadState *tstate = PyThreadState_GET();
value = tstate->curexc_value; PyObject* tmp_tb = tstate->curexc_traceback;
type = tstate->curexc_type; if (tb != tmp_tb) {
Py_INCREF(type);
Py_XINCREF(value);
Py_INCREF(tb); Py_INCREF(tb);
if (!value || value == Py_None) { tstate->curexc_traceback = tb;
PyErr_NormalizeException(&type, &value, &tb); value = tstate->curexc_value;
} if (value && value != Py_None) {
if (value) {
PyException_SetTraceback(value, tb); PyException_SetTraceback(value, tb);
__Pyx_ErrRestore(type, value, tb); }
Py_XDECREF(tmp_tb);
} }
} }
bad: bad:
return; return;
} }
......
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