[ZPT] CVS: Packages/TAL - TALDefs.py:1.11

tim@digicool.com tim@digicool.com
Fri, 16 Mar 2001 15:58:45 -0500 (EST)


Update of /cvs-repository/Packages/TAL
In directory korak:/tmp/cvs-serv12990

Modified Files:
	TALDefs.py 
Log Message:
Change exceptions to store lineno and offset info in separate attributes,
for consistency with nsgmllib and expat.



--- Updated File TALDefs.py in package Packages/TAL --
--- TALDefs.py	2001/03/16 20:38:05	1.10
+++ TALDefs.py	2001/03/16 20:58:45	1.11
@@ -111,16 +111,18 @@
     ]
 
 class TALError(Exception):
-    def __init__(self, msg, position=None):
+    def __init__(self, msg, position=(None, None)):
+        assert msg != ""
         self.msg = msg
-        self.position = position    # (line, offset) pair
+        self.lineno = position[0]
+        self.offset = position[1]
 
     def __str__(self):
-        if self.position:
-            result = "%s, at line %d, column %d" % (
-                self.msg, self.position[0], self.position[1]+1)
-        else:
-            result = self.msg
+        result = self.msg
+        if self.lineno is not None:
+            result = result + ", at line %d" % self.lineno
+        if self.offset is not None:
+            result = result + ", column %d" % (self.offset + 1)
         return result
 
 class METALError(TALError):