Blob Blame History Raw
--- a/src/Base/swigpyrun.cpp
+++ b/src/Base/swigpyrun.cpp
@@ -35,6 +35,16 @@
 # pragma GCC diagnostic ignored "-Wcast-function-type"
 # endif
 #endif
+
+/* Temporary workaround for PyInterpreterState being made private in Python
+ * 3.8.
+#if PY_VERSION_HEX >= 0x03080000
+# define Py_BUILD_CORE
+#  include "internal/pycore_pystate.h"
+# undef Py_BUILD_CORE
+#endif
+*/
+
 namespace Swig_python {
 #define SWIG_PYTHON_NO_BUILD_NONE
 #include <swigpyrun.h>
--- a/src/Base/swigpyrun.inl
+++ b/src/Base/swigpyrun.inl
@@ -72,7 +72,7 @@ void cleanupSWIG_T(const char* TypeName)
 
     PyObject *module, *dict;
     PyInterpreterState *interp = PyThreadState_GET()->interp;
-    PyObject *modules = interp->modules;
+    PyObject *modules = PyImport_GetModuleDict();
     module = PyDict_GetItemString(modules, "__builtin__");
     if (module != NULL && PyModule_Check(module)) {
         dict = PyModule_GetDict(module);