File tree 1 file changed +16
-3
lines changed
1 file changed +16
-3
lines changed Original file line number Diff line number Diff line change 36
36
#include < boost/python.hpp>
37
37
#include < boost/regex.hpp>
38
38
#include < boost/thread/condition_variable.hpp>
39
+ #include < boost/algorithm/string.hpp>
39
40
40
41
#include < sstream>
41
42
@@ -409,8 +410,21 @@ void PythonInterpreter::run_string( const std::string& command )
409
410
CORE_THROW_LOGICERROR ( " The python interpreter hasn't been initialized!" );
410
411
}
411
412
}
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 () )
414
428
{
415
429
{
416
430
PythonInterpreterPrivate::lock_type lock ( this ->private_ ->get_mutex () );
@@ -615,7 +629,6 @@ void PythonInterpreter::interrupt()
615
629
{
616
630
this ->error_signal_ ( " \n KeyboardInterrupt\n " );
617
631
this ->private_ ->command_buffer_ .clear ();
618
- this ->prompt_signal_ ( this ->private_ ->prompt1_ );
619
632
}
620
633
}
621
634
}
You can’t perform that action at this time.
0 commit comments