Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2015-08-04 11:34:20 +0300
committerCampbell Barton <ideasman42@gmail.com>2015-08-04 11:49:42 +0300
commitcff288cf3a0d71b610fa20875a321ea3b8db2388 (patch)
tree32d172a1953c6f5777690e616a8581fd8801be53 /source/blender/python/intern
parent62c8f46ab6f16f99bcf848936a690e01f4c9e770 (diff)
Use PyC_ParseBool to parse bools
This could cause problems since they could be any int, then passed directly to internal functions that assume bools.
Diffstat (limited to 'source/blender/python/intern')
-rw-r--r--source/blender/python/intern/bpy.c13
-rw-r--r--source/blender/python/intern/bpy_library.c14
-rw-r--r--source/blender/python/intern/bpy_operator.c13
-rw-r--r--source/blender/python/intern/bpy_props.c6
-rw-r--r--source/blender/python/intern/bpy_utils_units.c11
5 files changed, 40 insertions, 17 deletions
diff --git a/source/blender/python/intern/bpy.c b/source/blender/python/intern/bpy.c
index 9a5e488850e..fa2ad3a4803 100644
--- a/source/blender/python/intern/bpy.c
+++ b/source/blender/python/intern/bpy.c
@@ -114,13 +114,16 @@ static PyObject *bpy_blend_paths(PyObject *UNUSED(self), PyObject *args, PyObjec
int flag = 0;
PyObject *list;
- int absolute = false;
- int packed = false;
- int local = false;
+ bool absolute = false;
+ bool packed = false;
+ bool local = false;
static const char *kwlist[] = {"absolute", "packed", "local", NULL};
- if (!PyArg_ParseTupleAndKeywords(args, kw, "|iii:blend_paths",
- (char **)kwlist, &absolute, &packed, &local))
+ if (!PyArg_ParseTupleAndKeywords(
+ args, kw, "|O&O&O&:blend_paths", (char **)kwlist,
+ PyC_ParseBool, &absolute,
+ PyC_ParseBool, &packed,
+ PyC_ParseBool, &local))
{
return NULL;
}
diff --git a/source/blender/python/intern/bpy_library.c b/source/blender/python/intern/bpy_library.c
index 3b95b99a0a1..a5879f11e51 100644
--- a/source/blender/python/intern/bpy_library.c
+++ b/source/blender/python/intern/bpy_library.c
@@ -53,6 +53,7 @@
#include "bpy_util.h"
#include "bpy_library.h"
+#include "../generic/py_capi_utils.h"
#include "../generic/python_utildefines.h"
/* nifty feature. swap out strings for RNA data */
@@ -189,10 +190,17 @@ static PyObject *bpy_lib_load(PyObject *UNUSED(self), PyObject *args, PyObject *
static const char *kwlist[] = {"filepath", "link", "relative", NULL};
BPy_Library *ret;
const char *filename = NULL;
- int is_rel = 0, is_link = 0;
-
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "s|ii:load", (char **)kwlist, &filename, &is_link, &is_rel))
+ bool is_rel = false, is_link = false;
+
+ if (!PyArg_ParseTupleAndKeywords(
+ args, kwds,
+ "s|O&O&:load", (char **)kwlist,
+ &filename,
+ PyC_ParseBool, &is_link,
+ PyC_ParseBool, &is_rel))
+ {
return NULL;
+ }
ret = PyObject_New(BPy_Library, &bpy_lib_Type);
diff --git a/source/blender/python/intern/bpy_operator.c b/source/blender/python/intern/bpy_operator.c
index fc17173a5d4..7cccc204088 100644
--- a/source/blender/python/intern/bpy_operator.c
+++ b/source/blender/python/intern/bpy_operator.c
@@ -45,6 +45,7 @@
#include "bpy_rna.h" /* for setting arg props only - pyrna_py_to_prop() */
#include "bpy_util.h"
#include "../generic/bpy_internal_import.h"
+#include "../generic/py_capi_utils.h"
#include "../generic/python_utildefines.h"
#include "RNA_access.h"
@@ -311,8 +312,8 @@ static PyObject *pyop_as_string(PyObject *UNUSED(self), PyObject *args)
const char *opname;
PyObject *kw = NULL; /* optional args */
- int all_args = 1;
- int macro_args = 1;
+ bool all_args = true;
+ bool macro_args = true;
int error_val = 0;
char *buf = NULL;
@@ -325,8 +326,14 @@ static PyObject *pyop_as_string(PyObject *UNUSED(self), PyObject *args)
return NULL;
}
- if (!PyArg_ParseTuple(args, "s|O!ii:_bpy.ops.as_string", &opname, &PyDict_Type, &kw, &all_args, &macro_args))
+ if (!PyArg_ParseTuple(
+ args, "s|O!O&O&:_bpy.ops.as_string",
+ &opname, &PyDict_Type, &kw,
+ PyC_ParseBool, &all_args,
+ PyC_ParseBool, &macro_args))
+ {
return NULL;
+ }
ot = WM_operatortype_find(opname, true);
diff --git a/source/blender/python/intern/bpy_props.c b/source/blender/python/intern/bpy_props.c
index 6e70f97fd4e..19ded7fb4f3 100644
--- a/source/blender/python/intern/bpy_props.c
+++ b/source/blender/python/intern/bpy_props.c
@@ -1951,7 +1951,7 @@ static PyObject *BPy_BoolProperty(PyObject *self, PyObject *args, PyObject *kw)
"options", "subtype", "update", "get", "set", NULL};
const char *id = NULL, *name = NULL, *description = "";
int id_len;
- int def = 0;
+ bool def = false;
PropertyRNA *prop;
PyObject *pyopts = NULL;
int opts = 0;
@@ -1962,9 +1962,9 @@ static PyObject *BPy_BoolProperty(PyObject *self, PyObject *args, PyObject *kw)
PyObject *set_cb = NULL;
if (!PyArg_ParseTupleAndKeywords(args, kw,
- "s#|ssiO!sOOO:BoolProperty",
+ "s#|ssO&O!sOOO:BoolProperty",
(char **)kwlist, &id, &id_len,
- &name, &description, &def,
+ &name, &description, PyC_ParseBool, &def,
&PySet_Type, &pyopts, &pysubtype,
&update_cb, &get_cb, &set_cb))
{
diff --git a/source/blender/python/intern/bpy_utils_units.c b/source/blender/python/intern/bpy_utils_units.c
index d40e7e070ac..057df4ccd41 100644
--- a/source/blender/python/intern/bpy_utils_units.c
+++ b/source/blender/python/intern/bpy_utils_units.c
@@ -249,12 +249,17 @@ static PyObject *bpyunits_to_string(PyObject *UNUSED(self), PyObject *args, PyOb
char *usys_str = NULL, *ucat_str = NULL;
double value = 0.0;
- int precision = 3, split_unit = false, compatible_unit = false;
+ int precision = 3;
+ bool split_unit = false, compatible_unit = false;
int usys, ucat;
- if (!PyArg_ParseTupleAndKeywords(args, kw, "ssd|ipp:bpy.utils.units.to_string", (char **)kwlist,
- &usys_str, &ucat_str, &value, &precision, &split_unit, &compatible_unit))
+ if (!PyArg_ParseTupleAndKeywords(
+ args, kw,
+ "ssd|iO&O&:bpy.utils.units.to_string", (char **)kwlist,
+ &usys_str, &ucat_str, &value, &precision,
+ PyC_ParseBool, &split_unit,
+ PyC_ParseBool, &compatible_unit))
{
return NULL;
}