# HG changeset patch
# User Edouard Tisserant
# Date 1368693622 -32400
# Node ID 9708ed2a4ac2e4c288f1e90c46322941f7be3a57
# Parent  412e30abf7e5984c8ac85e4ab3b3caaf1ca1f5d6
Added more clear error message in case of access to non declared PLC global from python code

diff -r 412e30abf7e5 -r 9708ed2a4ac2 runtime/PLCObject.py
--- a/runtime/PLCObject.py	Thu May 16 14:47:57 2013 +0900
+++ b/runtime/PLCObject.py	Thu May 16 17:40:22 2013 +0900
@@ -266,11 +266,18 @@
         self.python_runtime_vars["PLCBinary"] = self.PLClibraryHandle
         class PLCSafeGlobals:
             def __getattr__(_self, name):
-                v = self.python_runtime_vars["_"+name+"_ctype"]()
+                try :
+                    t = self.python_runtime_vars["_"+name+"_ctype"]
+                except KeyError:
+                    raise KeyError("Try to get unknown shared global variable : %s"%name)
+                v = t()
                 r = self.python_runtime_vars["_PySafeGetPLCGlob_"+name](ctypes.byref(v))
                 return self.python_runtime_vars["_"+name+"_unpack"](v)
             def __setattr__(_self, name, value):
-                t = self.python_runtime_vars["_"+name+"_ctype"]
+                try :
+                    t = self.python_runtime_vars["_"+name+"_ctype"]
+                except KeyError:
+                    raise KeyError("Try to set unknown shared global variable : %s"%name)
                 v = self.python_runtime_vars["_"+name+"_pack"](t,value)
                 self.python_runtime_vars["_PySafeSetPLCGlob_"+name](ctypes.byref(v))
         self.python_runtime_vars["PLCGlobals"] = PLCSafeGlobals()