pyuno/source/loader/pyuno_loader.cxx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
New commits: commit cbe9a0a815e4a73bf8db425a7c5c651e67b2ed65 Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Mon Dec 28 19:23:10 2020 +0300 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Fri Jan 1 18:03:00 2021 +0100 Use Unicode paths on Windows for pyuno No need to convert to 8-byte string only to convert back to UTF-16. No idea if this has some logic on Linux, so only changing Windows. Change-Id: I87b7f25e5b1a2dd07ac3354f8f065485949ef229 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108480 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> diff --git a/pyuno/source/loader/pyuno_loader.cxx b/pyuno/source/loader/pyuno_loader.cxx index a8722dd835bb..1337ea8c78f9 100644 --- a/pyuno/source/loader/pyuno_loader.cxx +++ b/pyuno/source/loader/pyuno_loader.cxx @@ -23,6 +23,7 @@ #include <pyuno.hxx> #include <o3tl/any.hxx> +#include <o3tl/char16_t2wchar_t.hxx> #include <osl/process.h> #include <osl/file.hxx> @@ -109,16 +110,22 @@ static void setPythonHome ( const OUString & pythonHome ) { OUString systemPythonHome; osl_getSystemPathFromFileURL( pythonHome.pData, &(systemPythonHome.pData) ); - OString o = OUStringToOString( systemPythonHome, osl_getThreadTextEncoding() ); // static because Py_SetPythonHome just copies the "wide" pointer static wchar_t wide[PATH_MAX + 1]; +#if defined _WIN32 + const size_t len = systemPythonHome.getLength(); + if (len < std::size(wide)) + wcsncpy(wide, o3tl::toW(systemPythonHome.getStr()), len + 1); +#else + OString o = OUStringToOString(systemPythonHome, osl_getThreadTextEncoding()); size_t len = mbstowcs(wide, o.pData->buffer, PATH_MAX + 1); +#endif if(len == size_t(-1)) { PyErr_SetString(PyExc_SystemError, "invalid multibyte sequence in python home path"); return; } - if(len == PATH_MAX + 1) + if(len >= PATH_MAX + 1) { PyErr_SetString(PyExc_SystemError, "python home path is too long"); return; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits