[Lldb-commits] [lldb] r127191 - /lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp

Caroline Tice ctice at apple.com
Mon Mar 7 15:24:28 PST 2011


Author: ctice
Date: Mon Mar  7 17:24:28 2011
New Revision: 127191

URL: http://llvm.org/viewvc/llvm-project?rev=127191&view=rev
Log:

Add thread state initialization to the thread where the interactive
interpreter is run (which is separate from the thread where
Py_Initialize is called, where this normally gets set up).


Modified:
    lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp

Modified: lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp?rev=127191&r1=127190&r2=127191&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp (original)
+++ lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Mon Mar  7 17:24:28 2011
@@ -1384,10 +1384,16 @@
 	    // The following call drops into the embedded interpreter loop and stays there until the
 	    // user chooses to exit from the Python interpreter.
 
+        Py_BEGIN_ALLOW_THREADS
+        PyGILState_STATE gstate = PyGILState_Ensure();
+        
         run_string.Printf ("run_python_interpreter (%s)", script_interpreter->m_dictionary_name.c_str());
         PyRun_SimpleString (run_string.GetData());
         run_string.Clear ();
         
+        PyGILState_Release (gstate);
+        Py_END_ALLOW_THREADS
+        
         run_string.Printf ("run_one_line (%s, 'sys.stdin = save_stdin')", script_interpreter->m_dictionary_name.c_str());
         PyRun_SimpleString (run_string.GetData());
         run_string.Clear();
@@ -1474,6 +1480,7 @@
         ::setenv ("PYTHONPATH", pathon_path_env_cstr, 1);
     }
 
+    PyEval_InitThreads ();
     Py_Initialize ();
 
     PyObject *compiled_module = Py_CompileString (embedded_interpreter_string, 





More information about the lldb-commits mailing list