diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2016-03-23 15:58:31 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2016-03-23 15:58:31 +0300 |
commit | 21f31e60546f1f882494bacb84adee92a53d734c (patch) | |
tree | d5060a6523b0192200180bb8b7ffc985383cb160 /intern/cycles/blender | |
parent | 6e31f4f0900d07e1b54facc0127e1fd01c65a1c1 (diff) |
Fix T47856: Cycles problem when running from multi-byte path
This is a mix of regression and old unsupported configuration.
Regression was caused by some checks added on Blender side which was
checking whether python function returned error or not. This made it
impossible to enable Cycles when running from a file path which can't
be encoded with MBCS codepage.
Non-regression issue was that it wasn't possible to use pre-compiled
CUDA kernels when running from a path with non-ascii multi-byte
characters.
This commit fixes regression and CUDA parts, but OSL still can't be
used from a non-ascii location because it uses non-widechar API to
work with file paths by the looks of it. Not sure we can solve this
just from our side by using some codepage trick (UTF-16?) since even
oslc fails to compile shader when there are non-ascii characters in
the path.
Diffstat (limited to 'intern/cycles/blender')
-rw-r--r-- | intern/cycles/blender/blender_python.cpp | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/intern/cycles/blender/blender_python.cpp b/intern/cycles/blender/blender_python.cpp index 27eab0c7f68..b2294c8b68e 100644 --- a/intern/cycles/blender/blender_python.cpp +++ b/intern/cycles/blender/blender_python.cpp @@ -138,19 +138,29 @@ void python_thread_state_restore(void **python_thread_state) static const char *PyC_UnicodeAsByte(PyObject *py_str, PyObject **coerce) { -#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 */ - if(!PyUnicode_Check(py_str)) { - PyErr_BadArgument(); - return ""; + const char *result = _PyUnicode_AsString(py_str); + if(result) { + /* 99% of the time this is enough but we better support non unicode + * chars since blender doesnt limit this. + */ + return result; } -#endif - if((*coerce = PyUnicode_EncodeFSDefault(py_str))) { - return PyBytes_AS_STRING(*coerce); + else { + PyErr_Clear(); + if(PyBytes_Check(py_str)) { + return PyBytes_AS_STRING(py_str); + } + else if((*coerce = PyUnicode_EncodeFSDefault(py_str))) { + return PyBytes_AS_STRING(*coerce); + } + else { + /* Clear the error, so Cycles can be at leadt used without + * GPU and OSL support, + */ + PyErr_Clear(); + return ""; + } } - return ""; } static PyObject *init_func(PyObject * /*self*/, PyObject *args) |