Commit 04f4943d authored by Martin v. Löwis's avatar Martin v. Löwis

_exceptions: Format a missing system id as <unknown>.

expatreader: Use the error handler instead of raising exception directly.
parent 3383792c
...@@ -79,10 +79,11 @@ class SAXParseException(SAXException): ...@@ -79,10 +79,11 @@ class SAXParseException(SAXException):
def __str__(self): def __str__(self):
"Create a string representation of the exception." "Create a string representation of the exception."
return "%s at %s:%d:%d" % (self._msg, sysid = self.getSystemId()
self.getSystemId(), if sysid is None:
self.getLineNumber(), sysid = "<unknown>"
self.getColumnNumber()) return "%s:%d:%d: %s" % (sysid, self.getLineNumber(),
self.getColumnNumber(), self._msg)
# ===== SAXNOTRECOGNIZEDEXCEPTION ===== # ===== SAXNOTRECOGNIZEDEXCEPTION =====
......
...@@ -81,7 +81,8 @@ class ExpatParser(xmlreader.IncrementalParser, xmlreader.Locator): ...@@ -81,7 +81,8 @@ class ExpatParser(xmlreader.IncrementalParser, xmlreader.Locator):
self._parser.Parse(data, isFinal) self._parser.Parse(data, isFinal)
except expat.error: except expat.error:
error_code = self._parser.ErrorCode error_code = self._parser.ErrorCode
raise SAXParseException(expat.ErrorString(error_code), None, self) exc = SAXParseException(expat.ErrorString(error_code), None, self)
self._err_handler.fatalError(exc)
def close(self): def close(self):
if self._entity_stack: if self._entity_stack:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment