Move bpy_hydra.export_mtlx() exception handling to C code #28

Merged
Bogdan Nagirniak merged 9 commits from BLEN-392_pyerr_catch into hydra-render 2023-05-03 21:15:52 +02:00
Showing only changes of commit 0b701aa059 - Show all commits

View File

@ -81,14 +81,16 @@ void MaterialData::init()
}
else {
file_path = "";
std::string err_str;
/* Clearing exception data */
PyObject *type, *value, *traceback;
/* Clearing and logging exception data */
PyObject *type, *value, *traceback, *pstr;
PyErr_Fetch(&type, &value, &traceback);
PyErr_NormalizeException(&type, &value, &traceback);
std::string err_str = ((PyTypeObject *)type)->tp_name;
if (value) {
PyObject *pstr = PyObject_Str(value);
err_str = PyUnicode_AsUTF8(pstr);
err_str += ": ";
err_str += PyUnicode_AsUTF8(pstr);
Py_DECREF(pstr);
}
Py_XDECREF(traceback);