From 2f10c24081155236b80fa1b05d1ea2114f80ffd4 Mon Sep 17 00:00:00 2001 From: mpa Date: Tue, 8 Dec 2015 15:34:09 +0300 Subject: [PATCH] INT PAL 53005: Operators if/else, for, try/except, etc do not work in embedded Python console --- src/PyInterp/PyInterp_Interp.cxx | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) 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()) { -- 2.39.2