diff --git a/source/blender/python/intern/bpy_rna.cc b/source/blender/python/intern/bpy_rna.cc index 2b92daf5dc1..2653622e7da 100644 --- a/source/blender/python/intern/bpy_rna.cc +++ b/source/blender/python/intern/bpy_rna.cc @@ -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);