[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [59430] trunk/blender/release/scripts/ modules/bpy_types.py: Fix for an obscure bpy_types bug: When attempting to define __setattr__ in a metaclass based on RNAMetaPropGroup , the base class' __setattr__ method can not be called, since python prohibits setattr on

Lukas Toenne lukas.toenne at googlemail.com
Fri Aug 23 17:39:25 CEST 2013


Revision: 59430
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=59430
Author:   lukastoenne
Date:     2013-08-23 15:39:25 +0000 (Fri, 23 Aug 2013)
Log Message:
-----------
Fix for an obscure bpy_types bug: When attempting to define __setattr__ in a metaclass based on RNAMetaPropGroup, the base class' __setattr__ method can not be called, since python prohibits setattr on
builtin classes. This was done in Python 2.3 to prevent changes to the 'object' type definition and similar issues. As explained by Guido van Rossum in the following mail, the python check will look for
the *closest* base class, which fails for RNAMetaPropGroup because its first base is RNAMeta, which is in turn a subclass of 'type'.

http://code.activestate.com/lists/python-dev/34489/

The easiest and safest way to prevent this issue therefore seems to be
to swap the base class order for RNAMetaPropGroup, so that StructMetaPropGroup is the first base, which has a perfectly valid setattr implementation.

Modified Paths:
--------------
    trunk/blender/release/scripts/modules/bpy_types.py

Modified: trunk/blender/release/scripts/modules/bpy_types.py
===================================================================
--- trunk/blender/release/scripts/modules/bpy_types.py	2013-08-23 15:35:05 UTC (rev 59429)
+++ trunk/blender/release/scripts/modules/bpy_types.py	2013-08-23 15:39:25 UTC (rev 59430)
@@ -547,7 +547,7 @@
         self.order.remove(key)
 
 
-class RNAMetaPropGroup(RNAMeta, StructMetaPropGroup):
+class RNAMetaPropGroup(StructMetaPropGroup, RNAMeta):
     pass
 
 




More information about the Bf-blender-cvs mailing list