File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -383,6 +383,8 @@ void PythonInterpreter::initialize_eventhandler(bool needsSpecialPythonPathTreat
383383 Py_ExitStatusException (status);
384384 }
385385
386+ PyEval_SaveThread ();
387+
386388 PRINT_PY_INIT_DEBUG (8 );
387389
388390#else
@@ -732,30 +734,32 @@ void PythonInterpreter::run_script(const std::string& script)
732734 // Clear any previous Python errors.
733735 PyErr_Clear ();
734736
735- // Compile the script
736- boost::python::object code_obj;
737- try
738737 {
739- code_obj = this ->private_ ->compiler_ (script, " <script>" , " exec" );
740- }
741- catch (...)
742- {}
738+ // Compile the script
739+ boost::python::object code_obj;
740+ try
741+ {
742+ code_obj = this ->private_ ->compiler_ (script, " <script>" , " exec" );
743+ }
744+ catch (...)
745+ {}
743746
744- // If an error happened during compilation, print the error message
745- if (PyErr_Occurred ())
746- {
747- PyErr_Print ();
748- }
749- // If compilation succeeded and the code object is not Py_None
750- else if (code_obj)
751- {
752- boost::python::dict local_var;
753- PyObject* result = PyEval_EvalCode (code_obj.ptr (), this ->private_ ->globals_ .ptr (), local_var.ptr ());
754- Py_XDECREF (result);
747+ // If an error happened during compilation, print the error message
755748 if (PyErr_Occurred ())
756749 {
757750 PyErr_Print ();
758751 }
752+ // If compilation succeeded and the code object is not Py_None
753+ else if (code_obj)
754+ {
755+ boost::python::dict local_var;
756+ PyObject* result = PyEval_EvalCode (code_obj.ptr (), this ->private_ ->globals_ .ptr (), local_var.ptr ());
757+ Py_XDECREF (result);
758+ if (PyErr_Occurred ())
759+ {
760+ PyErr_Print ();
761+ }
762+ }
759763 }
760764
761765 // EXIT PYTHON
You can’t perform that action at this time.
0 commit comments