From 576b51f2fb10e4dbd9dee08c0da0d18b322fe118 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A4r=20Bj=C3=B6rklund?= Date: Sat, 5 Dec 2020 21:01:15 +0100 Subject: Fix a crash during python init Threadstate is not available and causes abort to be called. Also change how we set python home, saw some init errors because environment variable wasn't picked up. --- .../BuildDependencies/scripts/0_package.target-win10-arm.list | 2 +- .../BuildDependencies/scripts/0_package.target-win10-win32.list | 2 +- .../BuildDependencies/scripts/0_package.target-win10-x64.list | 2 +- project/BuildDependencies/scripts/0_package.target-win32.list | 2 +- project/BuildDependencies/scripts/0_package.target-x64.list | 2 +- xbmc/interfaces/python/XBPython.cpp | 9 +++++++-- 6 files changed, 12 insertions(+), 7 deletions(-) diff --git a/project/BuildDependencies/scripts/0_package.target-win10-arm.list b/project/BuildDependencies/scripts/0_package.target-win10-arm.list index 14b41b51cc..61804210b1 100644 --- a/project/BuildDependencies/scripts/0_package.target-win10-arm.list +++ b/project/BuildDependencies/scripts/0_package.target-win10-arm.list @@ -34,7 +34,7 @@ openssl-1.1.1d-win10-arm-v141-20200105.7z pcre-8.43-win10-arm-v141-20200105.7z pillow-6.2.1-win10-arm-v142-20200803.7z pycryptodome-3.9.4-win10-arm-v142-20200803.7z -python-3.8.5-win10-arm-v142-20200803.7z +python-3.8.5-win10-arm-v142-20201205.7z rapidjson-1.1.0-20200105.7z spdlog-1.5.0-win10-arm-v141-20200320-2.7z sqlite-3300100-win10-arm-v141-20200105.7z diff --git a/project/BuildDependencies/scripts/0_package.target-win10-win32.list b/project/BuildDependencies/scripts/0_package.target-win10-win32.list index c3545e0bcb..77a39c0814 100644 --- a/project/BuildDependencies/scripts/0_package.target-win10-win32.list +++ b/project/BuildDependencies/scripts/0_package.target-win10-win32.list @@ -34,7 +34,7 @@ openssl-1.1.1d-win10-win32-v141-20200105.7z pcre-8.43-win10-win32-v141-20200105.7z pillow-6.2.1-win10-win32-v142-20200803.7z pycryptodome-3.9.4-win10-win32-v142-20200803.7z -python-3.8.5-win10-win32-v142-20200803.7z +python-3.8.5-win10-win32-v142-20201205.7z rapidjson-1.1.0-20200105.7z spdlog-1.5.0-win10-win32-v141-20200320-2.7z sqlite-3300100-win10-win32-v141-20200105.7z diff --git a/project/BuildDependencies/scripts/0_package.target-win10-x64.list b/project/BuildDependencies/scripts/0_package.target-win10-x64.list index 0655359d8e..b3b8ddec7b 100644 --- a/project/BuildDependencies/scripts/0_package.target-win10-x64.list +++ b/project/BuildDependencies/scripts/0_package.target-win10-x64.list @@ -34,7 +34,7 @@ openssl-1.1.1d-win10-x64-v141-20200105.7z pcre-8.43-win10-x64-v141-20200105.7z pillow-6.2.1-win10-x64-v142-20200803.7z pycryptodome-3.9.4-win10-x64-v142-20200803.7z -python-3.8.5-win10-x64-v142-20200803.7z +python-3.8.5-win10-x64-v142-20201205.7z rapidjson-1.1.0-20200105.7z spdlog-1.5.0-win10-x64-v141-20200320.7z sqlite-3300100-win10-x64-v141-20200105.7z diff --git a/project/BuildDependencies/scripts/0_package.target-win32.list b/project/BuildDependencies/scripts/0_package.target-win32.list index ea06633ea3..3d3e7d5ac5 100644 --- a/project/BuildDependencies/scripts/0_package.target-win32.list +++ b/project/BuildDependencies/scripts/0_package.target-win32.list @@ -41,7 +41,7 @@ openssl-1.1.1d-win10-win32-v141-20200105.7z pcre-8.43-win32-v141-20200105.7z pillow-6.2.1-win32-v142-20200803.7z pycryptodome-3.9.4-win32-v142-20200803.7z -python-3.8.5-win32-v142-20200803.7z +python-3.8.5-win32-v142-20201205.7z rapidjson-1.1.0-20200105.7z shairplay-ce80e00-win32-v141-20200105.7z spdlog-1.5.0-win32-v141-20200320-2.7z diff --git a/project/BuildDependencies/scripts/0_package.target-x64.list b/project/BuildDependencies/scripts/0_package.target-x64.list index 81a780a167..e40f2ba372 100644 --- a/project/BuildDependencies/scripts/0_package.target-x64.list +++ b/project/BuildDependencies/scripts/0_package.target-x64.list @@ -38,7 +38,7 @@ openssl-1.1.1d-x64-v141-20200105.7z pcre-8.43-x64-v141-20200105.7z pillow-6.2.1-x64-v142-20200803.7z pycryptodome-3.9.4-x64-v142-20200803.7z -python-3.8.5-x64-v142-20200803.7z +python-3.8.5-x64-v142-20201205.7z rapidjson-1.1.0-20200105.7z shairplay-ce80e00-x64-v141-20200105.7z spdlog-1.5.0-x64-v141-20200320.7z diff --git a/xbmc/interfaces/python/XBPython.cpp b/xbmc/interfaces/python/XBPython.cpp index 017eea5e1b..a02b7d4415 100644 --- a/xbmc/interfaces/python/XBPython.cpp +++ b/xbmc/interfaces/python/XBPython.cpp @@ -28,6 +28,7 @@ #include "utils/JSONVariantWriter.h" #include "utils/Variant.h" #include "utils/log.h" +#include "utils/CharsetConverter.h" #ifdef TARGET_WINDOWS #include "platform/Environment.h" @@ -501,10 +502,14 @@ bool XBPython::OnScriptInitialized(ILanguageInvoker* invoker) CEnvironment::putenv(buf); buf = "PYTHONOPTIMIZE=1"; CEnvironment::putenv(buf); - buf = "PYTHONHOME=" + CSpecialProtocol::TranslatePath("special://xbmc/system/python"); - CEnvironment::putenv(buf); buf = "OS=win32"; CEnvironment::putenv(buf); + + std::wstring pythonHomeW; + CCharsetConverter::utf8ToW(CSpecialProtocol::TranslatePath("special://xbmc/system/python"), + pythonHomeW); + Py_SetPythonHome(pythonHomeW.c_str()); + #ifdef _DEBUG if (CSysInfo::GetWindowsDeviceFamily() == CSysInfo::Xbox) CEnvironment::putenv("PYTHONCASEOK=1"); -- cgit v1.2.3