Use PyThreadState_GetDict, avoid Python internals

Works around problems caused by exposing Py internals (Py_BUILD_CORE).

- Build error with GCC, Py3.6 & OpenMP
- Linking error on MSVC
This commit is contained in:
2015-09-26 11:58:31 +10:00
parent 02b7896423
commit 4aad17c622

View File

@@ -29,12 +29,6 @@
* BLI_string_utf8() for unicode conversion.
*/
/* TODO, resolve linking errors on win32 */
#ifndef _WIN32
/* needed for Py3.6+ to access Py_PyThreadState_Current */
#define Py_BUILD_CORE
#endif
#include <Python.h>
#include <frameobject.h>
@@ -671,8 +665,8 @@ void PyC_SetHomePath(const char *py_path_bundle)
bool PyC_IsInterpreterActive(void)
{
/* expanded PyThreadState_GET which won't throw an exception */
return (((PyThreadState *)_Py_atomic_load_relaxed(&_PyThreadState_Current)) != NULL);
/* instead of PyThreadState_Get, which calls Py_FatalError */
return (PyThreadState_GetDict() != NULL);
}
/* Would be nice if python had this built in