Fix #136294: Blender 4.4 is discarding exceptions occurred in operator's constructor

While using constructors in Operator classes is _really_ not
recommended, BPY code was a bit too eager to overwrite existing errors
with its own generic messages.

Now only generate these exceptions if there is no other exception
already set.
This commit is contained in:
Bastien Montagne
2025-03-21 11:29:59 +01:00
parent 3e595b0f30
commit 14913a447c

View File

@@ -8304,7 +8304,9 @@ static PyObject *pyrna_struct_CreatePyObject_from_type(const PointerRNA *ptr,
#endif
if (pyrna == nullptr) {
PyErr_SetString(PyExc_MemoryError, "couldn't create bpy_struct object");
if (!PyErr_Occurred()) {
PyErr_SetString(PyExc_MemoryError, "couldn't create bpy_struct object");
}
return nullptr;
}
@@ -9450,10 +9452,16 @@ static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, Param
}
else if (py_srna == nullptr) {
py_class_instance = nullptr;
if (PyErr_Occurred()) {
err = -1; /* So the error is not overridden below. */
}
}
else if (py_srna == Py_None) { /* Probably won't ever happen, but possible. */
Py_DECREF(py_srna);
py_class_instance = nullptr;
if (PyErr_Occurred()) {
err = -1; /* So the error is not overridden below. */
}
}
else {
#if 0
@@ -9510,7 +9518,9 @@ static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, Param
#endif
if (py_class_instance == nullptr) {
err = -1; /* So the error is not overridden below. */
if (PyErr_Occurred()) {
err = -1; /* So the error is not overridden below. */
}
}
Py_DECREF(py_srna);