Used Py3.6 feature by accident, check version

This commit is contained in:
2017-06-26 19:57:48 +10:00
parent 28b2f1c305
commit 21f088018a
2 changed files with 31 additions and 8 deletions

View File

@@ -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");

View File

@@ -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;