[Bf-blender-cvs] [039b11f3497] blender2.8: PyRNA: all optional args now must be keyword args

Campbell Barton noreply at git.blender.org
Tue Aug 28 05:48:48 CEST 2018


Commit: 039b11f3497731572e36904b03550438b706df34
Author: Campbell Barton
Date:   Tue Aug 28 13:50:24 2018 +1000
Branches: blender2.8
https://developer.blender.org/rB039b11f3497731572e36904b03550438b706df34

PyRNA: all optional args now must be keyword args

In some cases the RNA API should be updated to make arguments use the
'required' flag, instead of adjusting Python scripts.

See T47811

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

M	release/scripts/startup/bl_ui/properties_data_lightprobe.py
M	source/blender/python/intern/bpy_rna.c

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

diff --git a/release/scripts/startup/bl_ui/properties_data_lightprobe.py b/release/scripts/startup/bl_ui/properties_data_lightprobe.py
index 05be89d6264..4faf1fcef3d 100644
--- a/release/scripts/startup/bl_ui/properties_data_lightprobe.py
+++ b/release/scripts/startup/bl_ui/properties_data_lightprobe.py
@@ -78,7 +78,6 @@ class DATA_PT_lightprobe(DataButtonsPanel, Panel):
         elif probe.type == 'PLANAR':
             col = layout.column()
             col.prop(probe, "influence_distance", text="Distance")
-            col.prop(probe, "falloff")
         else:
             col = layout.column()
             col.prop(probe, "influence_type")
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c
index 30bd3bc5ca3..9de9f6179d6 100644
--- a/source/blender/python/intern/bpy_rna.c
+++ b/source/blender/python/intern/bpy_rna.c
@@ -5654,6 +5654,17 @@ static PyObject *pyrna_func_call(BPy_FunctionRNA *self, PyObject *args, PyObject
 		item = NULL;
 
 		if (i < pyargs_len) {
+			/* New in 2.8x, optional arguments must be keywords.  */
+			if (UNLIKELY((flag_parameter & PARM_REQUIRED) == 0)) {
+				PyErr_Format(PyExc_TypeError,
+				             "%.200s.%.200s(): required parameter \"%.200s\" to be a keyword argument!",
+				             RNA_struct_identifier(self_ptr->type),
+				             RNA_function_identifier(self_func),
+				             RNA_property_identifier(parm));
+				err = -1;
+				break;
+			}
+
 			item = PyTuple_GET_ITEM(args, i);
 			kw_arg = false;
 		}



More information about the Bf-blender-cvs mailing list