Skip to content

Commit

Permalink
Merge pull request xbmc#18903 from Paxxi/fix_python_init
Browse files Browse the repository at this point in the history
Fix a crash during python init
  • Loading branch information
Paxxi authored Dec 7, 2020
2 parents f98835b + 576b51f commit 8cc9e80
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 7 additions & 2 deletions xbmc/interfaces/python/XBPython.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit 8cc9e80

Please sign in to comment.