summaryrefslogtreecommitdiffstats
path: root/Lib/xml
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>2004-03-20 08:15:30 (GMT)
committerFred Drake <fdrake@acm.org>2004-03-20 08:15:30 (GMT)
commit6fd0b0d5bacb38ac88e74a767f11df2bb73ae49b (patch)
treede4d0d2fc4f3ad9e462719cecb61975ba8082e62 /Lib/xml
parent9de0a2ba9dba2794927b895e9a8473c9437bebd1 (diff)
downloadcpython-6fd0b0d5bacb38ac88e74a767f11df2bb73ae49b.zip
cpython-6fd0b0d5bacb38ac88e74a767f11df2bb73ae49b.tar.gz
cpython-6fd0b0d5bacb38ac88e74a767f11df2bb73ae49b.tar.bz2
commit the portion of PyXML patch #919008 that is relevant to the
standard library: str() of xml.sax.SAXParseException should not fail if the line and/or column number returned by the locator are None (tests added)
Diffstat (limited to 'Lib/xml')
-rw-r--r--Lib/xml/sax/_exceptions.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/Lib/xml/sax/_exceptions.py b/Lib/xml/sax/_exceptions.py
index 7f128f6..628e80d 100644
--- a/Lib/xml/sax/_exceptions.py
+++ b/Lib/xml/sax/_exceptions.py
@@ -91,8 +91,13 @@ class SAXParseException(SAXException):
sysid = self.getSystemId()
if sysid is None:
sysid = "<unknown>"
- return "%s:%d:%d: %s" % (sysid, self.getLineNumber(),
- self.getColumnNumber(), self._msg)
+ linenum = self.getLineNumber()
+ if linenum is None:
+ linenum = "?"
+ colnum = self.getColumnNumber()
+ if colnum is None:
+ colnum = "?"
+ return "%s:%s:%s: %s" % (sysid, linenum, colnum, self._msg)
# ===== SAXNOTRECOGNIZEDEXCEPTION =====