From 4aaab9b8ee02fcbba96bc6572f7a91934547a2cb Mon Sep 17 00:00:00 2001
From: Juraj Fedel <wtxnh-scribus@yahoo.com.au>
Date: Sun, 27 Sep 2015 15:39:50 +0200
Subject: [PATCH] Python error cleared too early.

---
 scribus/plugins/scriptplugin/scriptercore.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/scribus/plugins/scriptplugin/scriptercore.cpp b/scribus/plugins/scriptplugin/scriptercore.cpp
index 4ec6088..37b8318 100644
--- a/scribus/plugins/scriptplugin/scriptercore.cpp
+++ b/scribus/plugins/scriptplugin/scriptercore.cpp
@@ -331,8 +331,6 @@ void ScripterCore::slotRunScriptFile(QString fileName, QStringList arguments, bo
 		// other return value (most likely None anyway) and can ignore it.
 		if (result == NULL)
 		{
-			// We've already saved the exception text, so clear the exception
-			PyErr_Clear();
 			PyObject* errorMsgPyStr = PyMapping_GetItemString(globals, (char*)"_errorMsg");
 			if (errorMsgPyStr == NULL)
 			{
@@ -358,6 +356,8 @@ void ScripterCore::slotRunScriptFile(QString fileName, QStringList arguments, bo
 									+ tr("This message is in your clipboard too. Use Ctrl+V to paste it into bug tracker.")
 									+ "</p></qt>");
 			}
+			// We've already processed the exception text, so clear the exception
+			PyErr_Clear();
 		} // end if result == NULL
 		// Because 'result' may be NULL, not a PyObject*, we must call PyXDECREF not Py_DECREF
 		Py_XDECREF(result);
-- 
2.1.4

