workaround for bug in VS 2013 that occurs at Python init time

This commit is contained in:
wmayer
2018-04-15 19:05:06 +02:00
parent 4adeb7702d
commit 7ed84a6590
3 changed files with 38 additions and 1 deletions

View File

@@ -485,6 +485,12 @@ const char* InterpreterSingleton::init(int argc,char *argv[])
#else
Py_SetProgramName(argv[0]);
#endif
// There is a serious bug in VS from 2010 until 2013 where the file descriptor for stdin, stdout or stderr
// returns a valid value for GUI applications (i.e. subsytem = Windows) where it shouldn't.
// This causes Python to fail during initialization.
// A workaround is to use freopen on stdin, stdout and stderr. See the class Redirection inside main()
// https://bugs.python.org/issue17797#msg197474
//
Py_Initialize();
PyEval_InitThreads();
#if PY_MAJOR_VERSION >= 3
@@ -505,6 +511,7 @@ const char* InterpreterSingleton::init(int argc,char *argv[])
this->_global = PyEval_SaveThread();
}
#if PY_MAJOR_VERSION >= 3
PyGILStateLocker lock;
#if PY_MINOR_VERSION >= 5
return Py_EncodeLocale(Py_GetPath(),NULL);
#else