summaryrefslogtreecommitdiffstats
path: root/Lib/xml
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2001-03-22 15:34:02 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2001-03-22 15:34:02 (GMT)
commitb374dd3a818463592fa3ee8eb38f32b12d6e4a21 (patch)
treec3f316a7df6a40f6bc21ed0b88f96b96e4ca90ff /Lib/xml
parentffb963c7f699c9b6ab0debc1825a55ec8f98556f (diff)
downloadcpython-b374dd3a818463592fa3ee8eb38f32b12d6e4a21.zip
cpython-b374dd3a818463592fa3ee8eb38f32b12d6e4a21.tar.gz
cpython-b374dd3a818463592fa3ee8eb38f32b12d6e4a21.tar.bz2
Synchronize with 1.6 of PyXML:
Retrieve relevant information at construction time, as it may be lost when the exception is printed.
Diffstat (limited to 'Lib/xml')
-rw-r--r--Lib/xml/sax/_exceptions.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/Lib/xml/sax/_exceptions.py b/Lib/xml/sax/_exceptions.py
index e23b5f4..7f128f6 100644
--- a/Lib/xml/sax/_exceptions.py
+++ b/Lib/xml/sax/_exceptions.py
@@ -61,14 +61,22 @@ class SAXParseException(SAXException):
SAXException.__init__(self, msg, exception)
self._locator = locator
+ # We need to cache this stuff at construction time.
+ # If this exception is thrown, the objects through which we must
+ # traverse to get this information may be deleted by the time
+ # it gets caught.
+ self._systemId = self._locator.getSystemId()
+ self._colnum = self._locator.getColumnNumber()
+ self._linenum = self._locator.getLineNumber()
+
def getColumnNumber(self):
"""The column number of the end of the text where the exception
occurred."""
- return self._locator.getColumnNumber()
+ return self._colnum
def getLineNumber(self):
"The line number of the end of the text where the exception occurred."
- return self._locator.getLineNumber()
+ return self._linenum
def getPublicId(self):
"Get the public identifier of the entity where the exception occurred."
@@ -76,7 +84,7 @@ class SAXParseException(SAXException):
def getSystemId(self):
"Get the system identifier of the entity where the exception occurred."
- return self._locator.getSystemId()
+ return self._systemId
def __str__(self):
"Create a string representation of the exception."