From: mpa Date: Tue, 8 Dec 2015 12:34:09 +0000 (+0300) Subject: INT PAL 53005: Operators if/else, for, try/except, etc do not work in embedded Python... X-Git-Tag: V8_0_0a1~4 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=2f10c24081155236b80fa1b05d1ea2114f80ffd4;p=modules%2Fgui.git INT PAL 53005: Operators if/else, for, try/except, etc do not work in embedded Python console --- diff --git a/src/PyInterp/PyInterp_Interp.cxx b/src/PyInterp/PyInterp_Interp.cxx index 5da3c537f..f77fb1a8b 100644 --- a/src/PyInterp/PyInterp_Interp.cxx +++ b/src/PyInterp/PyInterp_Interp.cxx @@ -38,6 +38,8 @@ #include #include +#include + #define TOP_HISTORY_PY "--- top of history ---" #define BEGIN_HISTORY_PY "--- begin of history ---" @@ -450,13 +452,10 @@ static int compile_command(const char *command, PyObject * global_ctxt, PyObject std::string singleCommand = command; std::string commandArgs = ""; - if (singleCommand.size() > 0 && singleCommand.at(singleCommand.size()-1) == '\n') - singleCommand.erase(singleCommand.size()-1); - std::size_t pos = singleCommand.find("args:"); - if (pos != std::string::npos) { - commandArgs = singleCommand.substr(pos+5); - commandArgs = commandArgs.substr(0, commandArgs.length()-2); - singleCommand = singleCommand.substr(0, pos-1)+"\")"; + QRegExp rx("execfile\\s*\\(.*(args:.*)\"\\s*\\)"); + if (rx.indexIn(command) != -1) { + commandArgs = rx.cap(1).remove(0,5).toStdString(); // arguments of command + singleCommand = rx.cap().remove(rx.cap(1)).remove(" ").toStdString(); // command for execution without arguments } if (commandArgs.empty()) {