From f16b88d3af13f8faa37255fc889369ae495d0208 Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Wed, 8 Dec 2010 16:43:39 +0000 Subject: fix for #1028 git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@5181 17fca916-40b9-46aa-a4ea-0a15b648b75c --- src/modules/pythoncore/libkvipythoncore.cpp | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) (limited to 'src/modules') diff --git a/src/modules/pythoncore/libkvipythoncore.cpp b/src/modules/pythoncore/libkvipythoncore.cpp index 1acf97513..f14cf454e 100644 --- a/src/modules/pythoncore/libkvipythoncore.cpp +++ b/src/modules/pythoncore/libkvipythoncore.cpp @@ -71,7 +71,7 @@ KviPythonInterpreter::~KviPythonInterpreter() { done(); } - + bool KviPythonInterpreter::init() { // get the global lock @@ -100,7 +100,7 @@ bool KviPythonInterpreter::init() PyEval_ReleaseLock(); return true; } - + void KviPythonInterpreter::done() { if(!m_pThreadState)return; @@ -138,20 +138,6 @@ bool KviPythonInterpreter::execute( // swap in my thread state PyThreadState_Swap(m_pThreadState); - - -#if 0 // now it's done in the initialization function of the interpreter - //prepend some helping functions - QString szPreCode= QString("import kvirc\n" \ - "import sys\n" \ - "class kvirc_stderr_grabber:\n" \ - "\tdef write(self,s):\n" \ - "\t\tkvirc.error(s)\n" \ - "sys.stderr=kvirc_stderr_grabber()\n" - ); - PyRun_SimpleString(szPreCode.toUtf8().data()); -#endif - QString szVarCode = "aArgs = ["; bool bFirst = true; @@ -169,8 +155,11 @@ bool KviPythonInterpreter::execute( PyRun_SimpleString(szVarCode.toUtf8().data()); + //clean "cr" from the python code (ticket #1028) + QString szCleanCode = szCode; + szCleanCode.replace(QRegExp("\r\n?"), "\n"); // execute some python code - retVal = PyRun_SimpleString(szCode.toUtf8().data()); + retVal = PyRun_SimpleString(szCleanCode.toUtf8().data()); szRetVal.setNum(retVal); -- cgit v1.3.1-10-gc9f91