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>2013-10-17 13:58:36 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-10-17 13:58:36 +0400
commit6d5024828b064d07b1f85c8053ad26a593b36188 (patch)
tree8a83b430709c3e4cf08c173a0587340328c2e07d
parent992902cee0a4f22dc115bbe8dbce4064c35c74cf (diff)
add local _PyLong_AsInt() needed for python older then 3.3.2
-rw-r--r--source/blender/python/generic/py_capi_utils.c16
-rw-r--r--source/blender/python/generic/py_capi_utils.h4
2 files changed, 20 insertions, 0 deletions
diff --git a/source/blender/python/generic/py_capi_utils.c b/source/blender/python/generic/py_capi_utils.c
index 63f66afd8a8..8e90d484a9d 100644
--- a/source/blender/python/generic/py_capi_utils.c
+++ b/source/blender/python/generic/py_capi_utils.c
@@ -887,3 +887,19 @@ PyObject *PyC_FlagSet_FromBitfield(PyC_FlagSet *items, int flag)
return ret;
}
+
+/* compat only */
+#if PY_VERSION_HEX < 0x03030200
+int
+_PyLong_AsInt(PyObject *obj)
+{
+ int overflow;
+ long result = PyLong_AsLongAndOverflow(obj, &overflow);
+ if (overflow || result > INT_MAX || result < INT_MIN) {
+ PyErr_SetString(PyExc_OverflowError,
+ "Python int too large to convert to C int");
+ return -1;
+ }
+ return (int)result;
+}
+#endif
diff --git a/source/blender/python/generic/py_capi_utils.h b/source/blender/python/generic/py_capi_utils.h
index 8928642bc3e..c6792ddfc79 100644
--- a/source/blender/python/generic/py_capi_utils.h
+++ b/source/blender/python/generic/py_capi_utils.h
@@ -72,4 +72,8 @@ int PyC_FlagSet_ValueFromID(PyC_FlagSet *item, const char *identifier, int
int PyC_FlagSet_ToBitfield(PyC_FlagSet *items, PyObject *value, int *r_value, const char *error_prefix);
PyObject *PyC_FlagSet_FromBitfield(PyC_FlagSet *items, int flag);
+#if PY_VERSION_HEX < 0x03030200
+int _PyLong_AsInt(PyObject *obj);
+#endif
+
#endif /* __PY_CAPI_UTILS_H__ */