<rdar://problem/11862570> Fixing a potential crasher related to Python locking

llvm-svn: 161054
This commit is contained in:
Enrico Granata 2012-07-31 16:58:12 +00:00
parent 6b12f596ef
commit 008eaf8460
1 changed files with 2 additions and 2 deletions

View File

@ -367,7 +367,7 @@ ScriptInterpreterPython::PythonInputReaderManager::InputReaderCallback
StreamString run_string;
char error_str[1024];
const char *pty_slave_name = script_interpreter->m_embedded_python_pty.GetSlaveName (error_str, sizeof (error_str));
if (pty_slave_name != NULL)
if (pty_slave_name != NULL && PyThreadState_GetDict() != NULL)
{
run_string.Printf ("run_one_line (%s, 'save_stderr = sys.stderr')", script_interpreter->m_dictionary_name.c_str());
PyRun_SimpleString (run_string.GetData());
@ -474,7 +474,7 @@ ScriptInterpreterPython::PythonInputReaderManager::InputReaderCallback
StreamString run_string;
char error_str[1024];
const char *pty_slave_name = script_interpreter->m_embedded_python_pty.GetSlaveName (error_str, sizeof (error_str));
if (pty_slave_name != NULL)
if (pty_slave_name != NULL && PyThreadState_GetDict() != NULL)
{
run_string.Printf ("run_one_line (%s, 'sys.stdin = save_stdin')", script_interpreter->m_dictionary_name.c_str());
PyRun_SimpleString (run_string.GetData());