File tree Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Original file line number Diff line number Diff line change 3636#include < boost/python.hpp>
3737#include < boost/regex.hpp>
3838#include < boost/thread/condition_variable.hpp>
39+ #include < boost/algorithm/string.hpp>
3940
4041#include < sstream>
4142
@@ -409,8 +410,21 @@ void PythonInterpreter::run_string( const std::string& command )
409410 CORE_THROW_LOGICERROR ( " The python interpreter hasn't been initialized!" );
410411 }
411412 }
412-
413- if ( !this ->is_eventhandler_thread () )
413+
414+ std::string trimmed_command = command;
415+ boost::algorithm::trim ( trimmed_command );
416+ if ( trimmed_command == " help()" )
417+ {
418+ // trap help(), since it hangs interpreter and therefore the entire app
419+ CORE_LOG_DEBUG ( " Python help() trapped" );
420+ PyErr_Clear ();
421+ PyRun_SimpleString (" print(\" help() function ignored in interpreter\" )\n " );
422+ this ->private_ ->command_buffer_ .clear ();
423+ this ->prompt_signal_ ( this ->private_ ->prompt1_ );
424+ return ;
425+ }
426+
427+ if ( ! this ->is_eventhandler_thread () )
414428 {
415429 {
416430 PythonInterpreterPrivate::lock_type lock ( this ->private_ ->get_mutex () );
@@ -615,7 +629,6 @@ void PythonInterpreter::interrupt()
615629 {
616630 this ->error_signal_ ( " \n KeyboardInterrupt\n " );
617631 this ->private_ ->command_buffer_ .clear ();
618- this ->prompt_signal_ ( this ->private_ ->prompt1_ );
619632 }
620633 }
621634}
You can’t perform that action at this time.
0 commit comments