PyAPI: use _PyObject_LookupAttr
Unlike PyObject_GetAttr, this avoids setting the attribute error only to clear it - under some conditions.
This commit is contained in:
@@ -8253,16 +8253,20 @@ static PyObject *pyrna_register_class(PyObject *UNUSED(self), PyObject *py_class
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
/* call classed register method () */
|
/* call classed register method () */
|
||||||
py_cls_meth = PyObject_GetAttr(py_class, bpy_intern_str_register);
|
switch (_PyObject_LookupAttr(py_class, bpy_intern_str_register, &py_cls_meth)) {
|
||||||
if (py_cls_meth == NULL) {
|
case 1:
|
||||||
PyErr_Clear();
|
{
|
||||||
}
|
PyObject *ret = PyObject_CallObject(py_cls_meth, NULL);
|
||||||
else {
|
if (ret) {
|
||||||
PyObject *ret = PyObject_CallObject(py_cls_meth, NULL);
|
Py_DECREF(ret);
|
||||||
if (ret) {
|
}
|
||||||
Py_DECREF(ret);
|
else {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
else {
|
case -1:
|
||||||
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -8353,16 +8357,20 @@ static PyObject *pyrna_unregister_class(PyObject *UNUSED(self), PyObject *py_cla
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* call classed unregister method */
|
/* call classed unregister method */
|
||||||
py_cls_meth = PyObject_GetAttr(py_class, bpy_intern_str_unregister);
|
switch (_PyObject_LookupAttr(py_class, bpy_intern_str_unregister, &py_cls_meth)) {
|
||||||
if (py_cls_meth == NULL) {
|
case 1:
|
||||||
PyErr_Clear();
|
{
|
||||||
}
|
PyObject *ret = PyObject_CallObject(py_cls_meth, NULL);
|
||||||
else {
|
if (ret) {
|
||||||
PyObject *ret = PyObject_CallObject(py_cls_meth, NULL);
|
Py_DECREF(ret);
|
||||||
if (ret) {
|
}
|
||||||
Py_DECREF(ret);
|
else {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
else {
|
case -1:
|
||||||
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user