# HG changeset patch
# User Edouard Tisserant
# Date 1366791680 -32400
# Node ID fa7c5034c1d2f987870909ab9993962f4f93e819
# Parent  847d68c3e7ffd350f6b22a409553063b7c179efa
Better display of Python exceptions from Py_Eval

diff -r 847d68c3e7ff -r fa7c5034c1d2 runtime/PLCObject.py
--- a/runtime/PLCObject.py	Wed Apr 24 15:44:46 2013 +0900
+++ b/runtime/PLCObject.py	Wed Apr 24 17:21:20 2013 +0900
@@ -246,7 +246,7 @@
         for method in self.python_runtime_vars.get("_runtime_%s"%methodname, []):
             res,exp = self.evaluator(method)
             if exp is not None: 
-                self.LogMessage(0,traceback.format_exception(*exp))
+                self.LogMessage(0,'\n'.join(traceback.format_exception(*exp)))
 
     def PythonRuntimeInit(self):
         MethodNames = ["init", "start", "stop", "cleanup"]
@@ -309,7 +309,9 @@
                     compile_cache[FBID]=(cmd,AST)
                 result,exp = self.evaluator(eval,cmd,self.python_runtime_vars)
                 if exp is not None: 
-                    raise(exp[1])
+                    res = "#EXCEPTION : "+str(exp[1])
+                    self.LogMessage(1,('PyEval@0x%x(Code="%s") Exception "%s"')%(FBID,cmd,
+                        '\n'.join(traceback.format_exception(*exp))))
                 else:
                     res=str(result)
                 self.python_runtime_vars["FBID"]=None