When the current thread state is NULL, PyThreadState_Get() issues a fatal error.
Use a gentler API PyThreadState_GetDict(), instead.
rdar://problem/11292882
git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@156200 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Interpreter/ScriptInterpreterPython.cpp b/source/Interpreter/ScriptInterpreterPython.cpp
index 9272b7e..89e5cb3 100644
--- a/source/Interpreter/ScriptInterpreterPython.cpp
+++ b/source/Interpreter/ScriptInterpreterPython.cpp
@@ -386,7 +386,10 @@
// in some (rare) cases during cleanup Python may end up believing we have no thread state
// and PyImport_AddModule will crash if that is the case - since that seems to only happen
// when destroying the SBDebugger, we can make do without clearing up stdout and stderr
- if (PyThreadState_Get())
+
+ // rdar://problem/11292882
+ // When the current thread state is NULL, PyThreadState_Get() issues a fatal error.
+ if (PyThreadState_GetDict())
{
PyObject *sysmod = PyImport_AddModule ("sys");
PyObject *sysdict = PyModule_GetDict (sysmod);