aboutsummaryrefslogtreecommitdiffstats
path: root/src/modules/pythoncore
diff options
context:
space:
mode:
authorGravatar Fabio Bas2010-12-08 16:43:39 +0000
committerGravatar Fabio Bas2010-12-08 16:43:39 +0000
commitf16b88d3af13f8faa37255fc889369ae495d0208 (patch)
tree2f82efadbe5f7faa7a7f78ef6117afa4d578b114 /src/modules/pythoncore
parentfix for #1029 (diff)
downloadKVIrc-f16b88d3af13f8faa37255fc889369ae495d0208.tar.gz
KVIrc-f16b88d3af13f8faa37255fc889369ae495d0208.tar.bz2
KVIrc-f16b88d3af13f8faa37255fc889369ae495d0208.zip
fix for #1028
git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@5181 17fca916-40b9-46aa-a4ea-0a15b648b75c
Diffstat (limited to 'src/modules/pythoncore')
-rw-r--r--src/modules/pythoncore/libkvipythoncore.cpp23
1 files changed, 6 insertions, 17 deletions
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);