@@ -121,12 +121,12 @@ void PythonConsole::initPython(PythonHandler *pythonHandler)
121121void PythonConsole::pythonShowDialog ()
122122{
123123 assert (mp_consoleDlg);
124+ GILRelease release;
124125 if (mp_consoleDlg)
125126 {
126127 // Post the message to ourselves (on the right thread) to create the window
127128 if (!mp_consoleDlg->isCreated ())
128129 {
129- GILRelease release;
130130 CommunicationInfo commInfo;
131131 commInfo.internalMsg = PYSCR_SHOWCONSOLE;
132132 commInfo.srcModuleName = _T (" PythonScript.dll" );
@@ -277,23 +277,26 @@ void PythonConsole::queueComplete()
277277
278278void PythonConsole::consume (std::shared_ptr<std::string> statement)
279279{
280- GILLock gilLock;
281-
282280 bool continuePrompt = false ;
283- try
284- {
285- boost::python::object oldStdout = m_sys.attr (" stdout" );
286- m_sys.attr (" stdout" ) = boost::python::ptr (this );
287- PyObject* unicodeCommand = PyUnicode_FromEncodedObject (boost::python::str (statement->c_str ()).ptr (), " utf-8" , NULL );
288- boost::python::object result = m_pushFunc (boost::python::handle<PyObject>(unicodeCommand));
289- // Py_DECREF(unicodeCommand);
290- m_sys.attr (" stdout" ) = oldStdout;
291-
292- continuePrompt = boost::python::extract<bool >(result);
293- }
294- catch (...)
295281 {
296- PyErr_Print ();
282+ GILLock gilLock;
283+
284+ try
285+ {
286+ boost::python::object oldStdout = m_sys.attr (" stdout" );
287+ m_sys.attr (" stdout" ) = boost::python::ptr (this );
288+ PyObject* unicodeCommand = PyUnicode_FromEncodedObject (boost::python::str (statement->c_str ()).ptr (), " utf-8" , NULL );
289+ boost::python::object result = m_pushFunc (boost::python::handle<PyObject>(unicodeCommand));
290+ // Py_DECREF(unicodeCommand);
291+ m_sys.attr (" stdout" ) = oldStdout;
292+
293+ continuePrompt = boost::python::extract<bool >(result);
294+ }
295+ catch (...)
296+ {
297+ PyErr_Print ();
298+ }
299+
297300 }
298301
299302 assert (mp_consoleDlg);
0 commit comments