Fix PyRNA class registration w/ Python 3.7
authorCampbell Barton <ideasman42@gmail.com>
Thu, 12 Jul 2018 06:28:06 +0000 (08:28 +0200)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 12 Jul 2018 06:30:39 +0000 (08:30 +0200)
In Python3.7 this now raises an error.

source/blender/python/intern/bpy_rna.c

index 9052b6f580ab50f016ce4300bd311d207fa37a68..80b0aa7a51b40c7017f1ff3b0b49346784a5577c 100644 (file)
@@ -7577,10 +7577,12 @@ static int bpy_class_validate_recursive(PointerRNA *dummyptr, StructRNA *srna, v
                if (!(flag & PROP_REGISTER))
                        continue;
 
+               /* TODO(campbell): Use Python3.7x _PyObject_LookupAttr(), also in the macro below. */
                identifier = RNA_property_identifier(prop);
                item = PyObject_GetAttrString(py_class, identifier);
 
                if (item == NULL) {
+                       PyErr_Clear();
                        /* Sneaky workaround to use the class name as the bl_idname */
 
 #define     BPY_REPLACEMENT_STRING(rna_attr, py_attr)                         \
@@ -7596,6 +7598,9 @@ static int bpy_class_validate_recursive(PointerRNA *dummyptr, StructRNA *srna, v
                                        }                                                         \
                                        Py_DECREF(item);                                          \
                                }                                                             \
+                               else {                                                        \
+                                       PyErr_Clear();                                            \
+                               }                                                             \
                        }  /* intentionally allow else here */
 
                        if (false) {}  /* needed for macro */