From 0133bcaf38f6ecb5d6937c9b762026cc452720de Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 14 Oct 2020 16:15:44 +1100 Subject: Fix crash starting Blender with Python 3.9 In 3.8 and older the class held a reference to methods, this is no longer the case in 3.9. --- source/blender/python/intern/bpy_rna.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'source') diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index 7796d0a01a1..ce66cd6ee27 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -8131,9 +8131,8 @@ static int bpy_class_validate_recursive(PointerRNA *dummyptr, PyErr_Clear(); } else { - /* No need to keep a ref, the class owns it - * (technically we should keep a reference, but...). */ - Py_DECREF(item); + /* Store original so we can decrement it's reference before returning. */ + PyObject *item_orig = item; if (is_staticmethod) { if (PyMethod_Check(item) == 0) { @@ -8144,6 +8143,7 @@ static int bpy_class_validate_recursive(PointerRNA *dummyptr, py_class_name, RNA_function_identifier(func), Py_TYPE(item)->tp_name); + Py_DECREF(item_orig); return -1; } item = ((PyMethodObject *)item)->im_func; @@ -8157,6 +8157,7 @@ static int bpy_class_validate_recursive(PointerRNA *dummyptr, py_class_name, RNA_function_identifier(func), Py_TYPE(item)->tp_name); + Py_DECREF(item_orig); return -1; } } @@ -8197,9 +8198,11 @@ static int bpy_class_validate_recursive(PointerRNA *dummyptr, func_arg_count, arg_count); } + Py_DECREF(item_orig); return -1; } } + Py_DECREF(item_orig); } } -- cgit v1.2.3