[Bf-blender-cvs] [42089fcde08] blender-v2.83-release: Fix T86765: Custom properties are included in `__dir__`

Campbell Barton noreply at git.blender.org
Fri May 7 07:57:44 CEST 2021


Commit: 42089fcde087b3738312e52820a57504795c69f1
Author: Campbell Barton
Date:   Fri Apr 23 17:05:41 2021 +1000
Branches: blender-v2.83-release
https://developer.blender.org/rB42089fcde087b3738312e52820a57504795c69f1

Fix T86765: Custom properties are included in `__dir__`

Remove custom properties from `__dir__` method result since these
can't be accessed using `__getattr__`.

Introduced in the 2.5x Python API update.

===================================================================

M	source/blender/python/intern/bpy_rna.c

===================================================================

diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c
index 39485f322d4..c570e3f8d7a 100644
--- a/source/blender/python/intern/bpy_rna.c
+++ b/source/blender/python/intern/bpy_rna.c
@@ -4178,6 +4178,10 @@ static void pyrna_dir_members_rna(PyObject *list, PointerRNA *ptr)
     iterprop = RNA_struct_iterator_property(ptr->type);
 
     RNA_PROP_BEGIN (ptr, itemptr, iterprop) {
+      /* Custom-properties are exposed using `__getitem__`, exclude from `__dir__`. */
+      if (RNA_property_is_idprop(itemptr.data)) {
+        continue;
+      }
       nameptr = RNA_struct_name_get_alloc(&itemptr, name, sizeof(name), &namelen);
 
       if (nameptr) {



More information about the Bf-blender-cvs mailing list