|
|
@@ -156,8 +156,7 @@ PyObject *Dtool_Raise_AssertionError() {
|
|
|
#else
|
|
|
PyObject *message = PyString_FromString(notify->get_assert_error_message().c_str());
|
|
|
#endif
|
|
|
- Py_INCREF(PyExc_AssertionError);
|
|
|
- PyErr_Restore(PyExc_AssertionError, message, nullptr);
|
|
|
+ PyErr_SetObject(PyExc_AssertionError, message);
|
|
|
notify->clear_assert_failed();
|
|
|
return nullptr;
|
|
|
}
|
|
|
@@ -166,14 +165,7 @@ PyObject *Dtool_Raise_AssertionError() {
|
|
|
* Raises a TypeError with the given message, and returns NULL.
|
|
|
*/
|
|
|
PyObject *Dtool_Raise_TypeError(const char *message) {
|
|
|
- // PyErr_Restore is what PyErr_SetString would have ended up calling
|
|
|
- // eventually anyway, so we might as well just get to the point.
|
|
|
- Py_INCREF(PyExc_TypeError);
|
|
|
-#if PY_MAJOR_VERSION >= 3
|
|
|
- PyErr_Restore(PyExc_TypeError, PyUnicode_FromString(message), nullptr);
|
|
|
-#else
|
|
|
- PyErr_Restore(PyExc_TypeError, PyString_FromString(message), nullptr);
|
|
|
-#endif
|
|
|
+ PyErr_SetString(PyExc_TypeError, message);
|
|
|
return nullptr;
|
|
|
}
|
|
|
|
|
|
@@ -194,8 +186,7 @@ PyObject *Dtool_Raise_ArgTypeError(PyObject *obj, int param, const char *functio
|
|
|
function_name, param, type_name,
|
|
|
Py_TYPE(obj)->tp_name);
|
|
|
|
|
|
- Py_INCREF(PyExc_TypeError);
|
|
|
- PyErr_Restore(PyExc_TypeError, message, nullptr);
|
|
|
+ PyErr_SetObject(PyExc_TypeError, message);
|
|
|
return nullptr;
|
|
|
}
|
|
|
|
|
|
@@ -214,8 +205,7 @@ PyObject *Dtool_Raise_AttributeError(PyObject *obj, const char *attribute) {
|
|
|
"'%.100s' object has no attribute '%.200s'",
|
|
|
Py_TYPE(obj)->tp_name, attribute);
|
|
|
|
|
|
- Py_INCREF(PyExc_AttributeError);
|
|
|
- PyErr_Restore(PyExc_AttributeError, message, nullptr);
|
|
|
+ PyErr_SetObject(PyExc_AttributeError, message);
|
|
|
return nullptr;
|
|
|
}
|
|
|
|