diff options
author | Sybren A. Stüvel <sybren@blender.org> | 2020-08-21 13:34:41 +0300 |
---|---|---|
committer | Sybren A. Stüvel <sybren@blender.org> | 2020-08-21 13:34:41 +0300 |
commit | 27f0a19bdc09c785d4ef5f7ac2bcd97018bed489 (patch) | |
tree | 87d07a7c5ead6c032e0cab8b89fa5daf5f8343d6 /release | |
parent | 3bc09c1c1ec9c1699ac872bc643d3e38c250803f (diff) |
Cleanup: remove `exec()` calls from custom property editor
Remove `exec()` and `eval()` calls from `WM_OT_properties_edit` where
possible. This not only results in simpler, cleaner code, but also
removes the necessity for `repr(value)` to evaluate to a Python
expression that in turn evaluates to `value` again.
No functional changes.
Reviewed By: campbellbarton
Differential Revision: https://developer.blender.org/D8658
Diffstat (limited to 'release')
-rw-r--r-- | release/scripts/startup/bl_operators/wm.py | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py index 83039a5c333..2b8664882b7 100644 --- a/release/scripts/startup/bl_operators/wm.py +++ b/release/scripts/startup/bl_operators/wm.py @@ -1284,18 +1284,11 @@ class WM_OT_properties_edit(Operator): prop_type_old = type(item[prop_old]) rna_idprop_ui_prop_clear(item, prop_old) - exec_str = "del item[%r]" % prop_old - # print(exec_str) - exec(exec_str) + del item[prop_old] # Reassign - exec_str = "item[%r] = %s" % (prop, repr(value_eval)) - # print(exec_str) - exec(exec_str) - - exec_str = "item.property_overridable_library_set('[\"%s\"]', %s)" % (prop, self.is_overridable_library) - exec(exec_str) - + item[prop] = value_eval + item.property_overridable_library_set('["%s"]' % prop, self.is_overridable_library) rna_idprop_ui_prop_update(item, prop) self._last_prop[:] = [prop] @@ -1385,8 +1378,9 @@ class WM_OT_properties_edit(Operator): return {'CANCELLED'} # retrieve overridable static - exec_str = "item.is_property_overridable_library('[\"%s\"]')" % (self.property) - self.is_overridable_library = bool(eval(exec_str)) + is_overridable = item.is_property_overridable_library(f'["{self.property}"]') + self.is_overridable_library = bool(is_overridable) + # default default value prop_type, is_array = rna_idprop_value_item_type(self.get_value_eval()) |