[Bf-blender-cvs] [21f088018a6] blender2.8: Used Py3.6 feature by accident, check version

Campbell Barton noreply at git.blender.org
Mon Jun 26 11:52:21 CEST 2017


Commit: 21f088018a653131793ce159a36938b1d98f75e4
Author: Campbell Barton
Date:   Mon Jun 26 19:57:48 2017 +1000
Branches: blender2.8
https://developer.blender.org/rB21f088018a653131793ce159a36938b1d98f75e4

Used Py3.6 feature by accident, check version

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

M	source/blender/python/intern/bpy_manipulator_wrap.c
M	source/blender/python/intern/bpy_rna_manipulator.c

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

diff --git a/source/blender/python/intern/bpy_manipulator_wrap.c b/source/blender/python/intern/bpy_manipulator_wrap.c
index 53b6285e880..7d02c2963d7 100644
--- a/source/blender/python/intern/bpy_manipulator_wrap.c
+++ b/source/blender/python/intern/bpy_manipulator_wrap.c
@@ -58,8 +58,6 @@ static bool bpy_manipulatortype_target_property_def(
 {
 	/* Note: names based on 'rna_rna.c' */
 	PyObject *empty_tuple = PyTuple_New(0);
-	static const char * const _keywords[] = {"id", "type", "array_length", NULL};
-	static _PyArg_Parser _parser = {"|$ssi:register_class", _keywords, 0};
 
 	struct {
 		char *id;
@@ -72,15 +70,28 @@ static bool bpy_manipulatortype_target_property_def(
 		.array_length = 1,
 	};
 
+	static const char * const _keywords[] = {"id", "type", "array_length", NULL};
+#define KW_FMT "|$ssi:register_class"
+#if PY_VERSION_HEX >= 0x03060000
+	static _PyArg_Parser _parser = {KW_FMT, _keywords, 0};
 	if (!_PyArg_ParseTupleAndKeywordsFast(
 	        empty_tuple, item,
 	        &_parser,
 	        &params.id,
 	        &params.type_id,
 	        &params.array_length))
+#else
+	if (!PyArg_ParseTupleAndKeywords(
+	        empty_tuple, item,
+	        KW_FMT, (char **)_keywords,
+	        &params.id,
+	        &params.type_id,
+	        &params.array_length))
+#endif
 	{
 		goto fail;
 	}
+#undef KW_FMT
 
 	if (params.id == NULL) {
 		PyErr_SetString(PyExc_ValueError, "'id' argument not given");
diff --git a/source/blender/python/intern/bpy_rna_manipulator.c b/source/blender/python/intern/bpy_rna_manipulator.c
index 245735f679e..d4f9a52db8d 100644
--- a/source/blender/python/intern/bpy_rna_manipulator.c
+++ b/source/blender/python/intern/bpy_rna_manipulator.c
@@ -238,12 +238,6 @@ PyDoc_STRVAR(bpy_manipulator_target_set_handler_doc,
 );
 static PyObject *bpy_manipulator_target_set_handler(PyObject *UNUSED(self), PyObject *args, PyObject *kwds)
 {
-	/* Note: this is a counter-part to functions:
-	 * 'Manipulator.target_set_prop & target_set_operator'
-	 * (see: rna_wm_manipulator_api.c). conventions should match. */
-	static const char * const _keywords[] = {"self", "target", "get", "set", "range", NULL};
-	static _PyArg_Parser _parser = {"Os|$OOO:target_set_handler", _keywords, 0};
-
 	PyGILState_STATE gilstate = PyGILState_Ensure();
 
 	struct {
@@ -256,6 +250,13 @@ static PyObject *bpy_manipulator_target_set_handler(PyObject *UNUSED(self), PyOb
 		.py_fn_slots = {NULL},
 	};
 
+	/* Note: this is a counter-part to functions:
+	 * 'Manipulator.target_set_prop & target_set_operator'
+	 * (see: rna_wm_manipulator_api.c). conventions should match. */
+	static const char * const _keywords[] = {"self", "target", "get", "set", "range", NULL};
+#define KW_FMT "Os|$OOO:target_set_handler"
+#if PY_VERSION_HEX >= 0x03070000
+	static _PyArg_Parser _parser = {KW_FMT, _keywords, 0};
 	if (!_PyArg_ParseTupleAndKeywordsFast(
 	        args, kwds,
 	        &_parser,
@@ -264,9 +265,20 @@ static PyObject *bpy_manipulator_target_set_handler(PyObject *UNUSED(self), PyOb
 	        &params.py_fn_slots[BPY_MANIPULATOR_FN_SLOT_GET],
 	        &params.py_fn_slots[BPY_MANIPULATOR_FN_SLOT_SET],
 	        &params.py_fn_slots[BPY_MANIPULATOR_FN_SLOT_RANGE_GET]))
+#else
+	if (!PyArg_ParseTupleAndKeywords(
+	        args, kwds,
+	        KW_FMT, (char **)_keywords,
+	        &params.self,
+	        &params.target,
+	        &params.py_fn_slots[BPY_MANIPULATOR_FN_SLOT_GET],
+	        &params.py_fn_slots[BPY_MANIPULATOR_FN_SLOT_SET],
+	        &params.py_fn_slots[BPY_MANIPULATOR_FN_SLOT_RANGE_GET]))
+#endif
 	{
 		goto fail;
 	}
+#undef KW_FMT
 
 	wmManipulator *mpr = ((BPy_StructRNA *)params.self)->ptr.data;




More information about the Bf-blender-cvs mailing list