diff options
Diffstat (limited to 'source/blender/python/generic/py_capi_utils.c')
-rw-r--r-- | source/blender/python/generic/py_capi_utils.c | 37 |
1 files changed, 11 insertions, 26 deletions
diff --git a/source/blender/python/generic/py_capi_utils.c b/source/blender/python/generic/py_capi_utils.c index 195442d34f6..d944cb435d0 100644 --- a/source/blender/python/generic/py_capi_utils.c +++ b/source/blender/python/generic/py_capi_utils.c @@ -646,10 +646,12 @@ PyObject *PyC_ExceptionBuffer(void) goto error_cleanup; } - Py_INCREF(stdout_backup); // since these were borrowed we don't want them freed when replaced. + /* Since these were borrowed we don't want them freed when replaced. */ + Py_INCREF(stdout_backup); Py_INCREF(stderr_backup); - PySys_SetObject("stdout", string_io); // both of these are freed when restoring + /* Both of these are freed when restoring. */ + PySys_SetObject("stdout", string_io); PySys_SetObject("stderr", string_io); PyErr_Restore(error_type, error_value, error_traceback); @@ -887,22 +889,10 @@ void PyC_MainModule_Restore(PyObject *main_mod) * - Must be called before #Py_Initialize. * - Expects output of `BKE_appdir_folder_id(BLENDER_PYTHON, NULL)`. * - Note that the `PYTHONPATH` environment variable isn't reliable, see T31506. - Use #Py_SetPythonHome instead. + * Use #Py_SetPythonHome instead. */ void PyC_SetHomePath(const char *py_path_bundle) { - if (py_path_bundle == NULL) { - /* Common enough to have bundled *nix python but complain on OSX/Win */ -# if defined(__APPLE__) || defined(_WIN32) - fprintf(stderr, - "Warning! bundled python not found and is expected on this platform. " - "(if you built with CMake: 'install' target may have not been built)\n"); -# endif - return; - } - /* set the environment path */ - printf("found bundled python: %s\n", py_path_bundle); - # ifdef __APPLE__ /* OSX allow file/directory names to contain : character (represented as / in the Finder) * but current Python lib (release 3.1.1) doesn't handle these correctly */ @@ -913,19 +903,14 @@ void PyC_SetHomePath(const char *py_path_bundle) } # endif - { - wchar_t py_path_bundle_wchar[1024]; - - /* Can't use this, on linux gives bug: #23018, - * TODO: try LANG="en_US.UTF-8" /usr/bin/blender, suggested 2008 */ - /* mbstowcs(py_path_bundle_wchar, py_path_bundle, FILE_MAXDIR); */ + /* Set the environment path. */ + wchar_t py_path_bundle_wchar[1024]; - BLI_strncpy_wchar_from_utf8( - py_path_bundle_wchar, py_path_bundle, ARRAY_SIZE(py_path_bundle_wchar)); + /* Can't use `mbstowcs` on linux gives bug: T23018. */ + BLI_strncpy_wchar_from_utf8( + py_path_bundle_wchar, py_path_bundle, ARRAY_SIZE(py_path_bundle_wchar)); - Py_SetPythonHome(py_path_bundle_wchar); - // printf("found python (wchar_t) '%ls'\n", py_path_bundle_wchar); - } + Py_SetPythonHome(py_path_bundle_wchar); } bool PyC_IsInterpreterActive(void) |