Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions src/Core/Python/PythonInterpreter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include <boost/python.hpp>
#include <boost/regex.hpp>
#include <boost/thread/condition_variable.hpp>
#include <boost/algorithm/string.hpp>

#include <sstream>

Expand Down Expand Up @@ -409,8 +410,21 @@ void PythonInterpreter::run_string( const std::string& command )
CORE_THROW_LOGICERROR( "The python interpreter hasn't been initialized!" );
}
}

if ( !this->is_eventhandler_thread() )

std::string trimmed_command = command;
boost::algorithm::trim( trimmed_command );
if ( trimmed_command == "help()" )
{
// trap help(), since it hangs interpreter and therefore the entire app
CORE_LOG_DEBUG( "Python help() trapped" );
PyErr_Clear();
PyRun_SimpleString("print(\"help() function ignored in interpreter\")\n");
this->private_->command_buffer_.clear();
this->prompt_signal_( this->private_->prompt1_ );
return;
}

if ( ! this->is_eventhandler_thread() )
{
{
PythonInterpreterPrivate::lock_type lock( this->private_->get_mutex() );
Expand Down Expand Up @@ -615,7 +629,6 @@ void PythonInterpreter::interrupt()
{
this->error_signal_( "\nKeyboardInterrupt\n" );
this->private_->command_buffer_.clear();
this->prompt_signal_( this->private_->prompt1_ );
}
}
}
Expand Down