Fix T58772: Stray "forward" and "up" options in 2.8 import addons?
authorBastien Montagne <montagne29@wanadoo.fr>
Wed, 5 Dec 2018 09:57:08 +0000 (10:57 +0100)
committerBastien Montagne <montagne29@wanadoo.fr>
Wed, 5 Dec 2018 10:08:57 +0000 (11:08 +0100)
Nice side-effect of using new __annotations__ thingy to store
dynamically-generated fields in a class: __annotations__ dict is not
ensured to exist for a given class, so we may end up modifying on of the
parents' one!

release/scripts/modules/bpy_extras/io_utils.py

index 4b28a9edf70b23834e67607886a08195c57e6d0c..420c2bfc9298c4d3fb1ec3067930bb5a2195599e 100644 (file)
@@ -127,6 +127,11 @@ def orientation_helper(axis_forward='Y', axis_up='Z'):
     with specified default values (axes).
     """
     def wrapper(cls):
+        # Without that, we may end up adding those fields to some **parent** class' __annotations__ property
+        # (like the ImportHelper or ExportHelper ones)! See T58772.
+        if "__annotations__" not in cls.__dict__:
+            cls.__dict__["__annotations__"] = {}
+
         def _update_axis_forward(self, context):
             if self.axis_forward[-1] == self.axis_up[-1]:
                 self.axis_up = (self.axis_up[0:-1] +