Commit ac14abe9 authored by Stefan Behnel's avatar Stefan Behnel

back out the last two exception raising changes

parent 91bbd1ee
...@@ -135,7 +135,7 @@ raise_error: ...@@ -135,7 +135,7 @@ raise_error:
#else /* Python 3+ */ #else /* Python 3+ */
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) { static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
PyObject *owned_type = NULL, *owned_value = NULL, *owned_tb = NULL; PyObject* owned_instance = NULL;
if (tb == Py_None) { if (tb == Py_None) {
tb = 0; tb = 0;
} else if (tb && !PyTraceBack_Check(tb)) { } else if (tb && !PyTraceBack_Check(tb)) {
...@@ -143,9 +143,11 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject ...@@ -143,9 +143,11 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject
"raise: arg 3 must be a traceback or None"); "raise: arg 3 must be a traceback or None");
goto bad; goto bad;
} }
if (value == Py_None)
value = 0;
if (PyExceptionInstance_Check(type)) { if (PyExceptionInstance_Check(type)) {
if (value && value != Py_None) { if (value) {
PyErr_SetString(PyExc_TypeError, PyErr_SetString(PyExc_TypeError,
"instance exception may not have a separate value"); "instance exception may not have a separate value");
goto bad; goto bad;
...@@ -154,11 +156,21 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject ...@@ -154,11 +156,21 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject
type = (PyObject*) Py_TYPE(value); type = (PyObject*) Py_TYPE(value);
} else if (PyExceptionClass_Check(type)) { } else if (PyExceptionClass_Check(type)) {
// instantiate the type now (we don't know when and how it will be caught) // instantiate the type now (we don't know when and how it will be caught)
PyErr_NormalizeException(&type, &value, &owned_tb); PyObject *args;
if (!tb && owned_tb) if (!value)
tb = owned_tb; args = PyTuple_New(0);
owned_type = type; else if (PyTuple_Check(value)) {
owned_value = value; Py_INCREF(value);
args = value;
} else
args = PyTuple_Pack(1, value);
if (!args)
goto bad;
owned_instance = PyEval_CallObject(type, args);
Py_DECREF(args);
if (!owned_instance)
goto bad;
value = owned_instance;
if (!PyExceptionInstance_Check(value)) { if (!PyExceptionInstance_Check(value)) {
PyErr_Format(PyExc_TypeError, PyErr_Format(PyExc_TypeError,
"calling %R should have returned an instance of " "calling %R should have returned an instance of "
...@@ -210,10 +222,7 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject ...@@ -210,10 +222,7 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject
} }
bad: bad:
Py_XDECREF(owned_type); Py_XDECREF(owned_instance);
Py_XDECREF(owned_value);
Py_XDECREF(owned_tb);
return; return;
} }
#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