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:
@@ -29,12 +29,6 @@
|
|||||||
* BLI_string_utf8() for unicode conversion.
|
* 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 <Python.h>
|
||||||
#include <frameobject.h>
|
#include <frameobject.h>
|
||||||
|
|
||||||
@@ -671,8 +665,8 @@ void PyC_SetHomePath(const char *py_path_bundle)
|
|||||||
|
|
||||||
bool PyC_IsInterpreterActive(void)
|
bool PyC_IsInterpreterActive(void)
|
||||||
{
|
{
|
||||||
/* expanded PyThreadState_GET which won't throw an exception */
|
/* instead of PyThreadState_Get, which calls Py_FatalError */
|
||||||
return (((PyThreadState *)_Py_atomic_load_relaxed(&_PyThreadState_Current)) != NULL);
|
return (PyThreadState_GetDict() != NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Would be nice if python had this built in
|
/* Would be nice if python had this built in
|
||||||
|
Reference in New Issue
Block a user