diff options
Diffstat (limited to 'graphics/Blender/patch-2.76b-use-python35.diff')
-rw-r--r-- | graphics/Blender/patch-2.76b-use-python35.diff | 170 |
1 files changed, 170 insertions, 0 deletions
diff --git a/graphics/Blender/patch-2.76b-use-python35.diff b/graphics/Blender/patch-2.76b-use-python35.diff new file mode 100644 index 0000000000000..176908b59e937 --- /dev/null +++ b/graphics/Blender/patch-2.76b-use-python35.diff @@ -0,0 +1,170 @@ +--- source/blender/python/generic/py_capi_utils.h.orig 2015-11-02 23:25:38.000000000 +1000 ++++ source/blender/python/generic/py_capi_utils.h 2016-01-08 19:16:13.796355344 +1000 +@@ -79,7 +79,7 @@ + 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); + +-int PyC_RunString_AsNumber(const char *expr, double *value, const char *filename); ++bool PyC_RunString_AsNumber(const char *expr, double *value, const char *filename); + + int PyC_ParseBool(PyObject *o, void *p); + +--- source/blender/python/generic/py_capi_utils.c.orig 2015-11-04 20:02:15.000000000 +1000 ++++ source/blender/python/generic/py_capi_utils.c 2016-01-08 19:16:13.784355344 +1000 +@@ -29,7 +29,6 @@ + * BLI_string_utf8() for unicode conversion. + */ + +- + #include <Python.h> + #include <frameobject.h> + +@@ -39,8 +38,10 @@ + + #include "python_utildefines.h" + ++#ifndef MATH_STANDALONE + /* only for BLI_strncpy_wchar_from_utf8, should replace with py funcs but too late in release now */ + #include "BLI_string_utf8.h" ++#endif + + #ifdef _WIN32 + #include "BLI_path_util.h" /* BLI_setenv() */ +@@ -200,6 +201,27 @@ + } + } + ++/** ++ * Use with PyArg_ParseTuple's "O&" formatting. ++ */ ++int PyC_ParseBool(PyObject *o, void *p) ++{ ++ bool *bool_p = p; ++ long value; ++ if (((value = PyLong_AsLong(o)) == -1) || !ELEM(value, 0, 1)) { ++ PyErr_Format(PyExc_ValueError, ++ "expected a bool or int (0/1), got %s", ++ Py_TYPE(o)->tp_name); ++ return 0; ++ } ++ ++ *bool_p = value ? true : false; ++ return 1; ++} ++ ++ ++#ifndef MATH_STANDALONE ++ + /* for debugging */ + void PyC_ObSpit(const char *name, PyObject *var) + { +@@ -534,15 +556,6 @@ + if (PyBytes_Check(py_str)) { + return PyBytes_AS_STRING(py_str); + } +-#ifdef WIN32 +- /* bug [#31856] oddly enough, Python3.2 --> 3.3 on Windows will throw an +- * exception here this needs to be fixed in python: +- * see: bugs.python.org/issue15859 */ +- else if (!PyUnicode_Check(py_str)) { +- PyErr_BadArgument(); +- return NULL; +- } +-#endif + else if ((*coerce = PyUnicode_EncodeFSDefault(py_str))) { + return PyBytes_AS_STRING(*coerce); + } +@@ -711,7 +724,7 @@ + } + + if (ret == NULL) { +- printf("PyC_InlineRun error, line:%d\n", __LINE__); ++ printf("%s error, line:%d\n", __func__, __LINE__); + PyErr_Print(); + PyErr_Clear(); + +@@ -785,7 +798,7 @@ + Py_DECREF(ret); + } + else { +- printf("PyC_InlineRun error on arg '%d', line:%d\n", i, __LINE__); ++ printf("%s error on arg '%d', line:%d\n", __func__, i, __LINE__); + PyC_ObSpit("failed converting:", item_new); + PyErr_Print(); + PyErr_Clear(); +@@ -796,11 +809,11 @@ + va_end(vargs); + } + else { +- printf("PyC_InlineRun error, 'values' not a list, line:%d\n", __LINE__); ++ printf("%s error, 'values' not a list, line:%d\n", __func__, __LINE__); + } + } + else { +- printf("PyC_InlineRun error line:%d\n", __LINE__); ++ printf("%s error line:%d\n", __func__, __LINE__); + PyErr_Print(); + PyErr_Clear(); + } +@@ -958,14 +971,14 @@ + + + /** +- * \return -1 on error, else 0 ++ * \return success + * + * \note it is caller's responsibility to acquire & release GIL! + */ +-int PyC_RunString_AsNumber(const char *expr, double *value, const char *filename) ++bool PyC_RunString_AsNumber(const char *expr, double *value, const char *filename) + { + PyObject *py_dict, *mod, *retval; +- int error_ret = 0; ++ bool ok = true; + PyObject *main_mod = NULL; + + PyC_MainModule_Backup(&main_mod); +@@ -985,7 +998,7 @@ + retval = PyRun_String(expr, Py_eval_input, py_dict, py_dict); + + if (retval == NULL) { +- error_ret = -1; ++ ok = false; + } + else { + double val; +@@ -1011,7 +1024,7 @@ + Py_DECREF(retval); + + if (val == -1 && PyErr_Occurred()) { +- error_ret = -1; ++ ok = false; + } + else if (!finite(val)) { + *value = 0.0; +@@ -1023,23 +1036,7 @@ + + PyC_MainModule_Restore(main_mod); + +- return error_ret; ++ return ok; + } + +-/** +- * Use with PyArg_ParseTuple's "O&" formatting. +- */ +-int PyC_ParseBool(PyObject *o, void *p) +-{ +- bool *bool_p = p; +- long value; +- if (((value = PyLong_AsLong(o)) == -1) || !ELEM(value, 0, 1)) { +- PyErr_Format(PyExc_ValueError, +- "expected a bool or int (0/1), got %s", +- Py_TYPE(o)->tp_name); +- return 0; +- } +- +- *bool_p = value ? true : false; +- return 1; +-} ++#endif /* #ifndef MATH_STANDALONE */ |