diff options
author | Fred Drake <fdrake@acm.org> | 2004-03-20 08:15:30 +0000 |
---|---|---|
committer | Fred Drake <fdrake@acm.org> | 2004-03-20 08:15:30 +0000 |
commit | b64d737056cf08aa6750239fb60f5c7d69b1bbf9 (patch) | |
tree | 20dfa4846366bbb1f27eb165eeaeaa5e2c3066f4 /Lib/test/test_sax.py | |
parent | a42b4b80bbf8fb54494e2a6408ca6a87c6c0b894 (diff) | |
download | cpython-b64d737056cf08aa6750239fb60f5c7d69b1bbf9.tar.gz |
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/test/test_sax.py')
-rw-r--r-- | Lib/test/test_sax.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/Lib/test/test_sax.py b/Lib/test/test_sax.py index af97888793..8e279ce520 100644 --- a/Lib/test/test_sax.py +++ b/Lib/test/test_sax.py @@ -489,6 +489,41 @@ def test_expat_incomplete(): else: return 0 +def test_sax_parse_exception_str(): + # pass various values from a locator to the SAXParseException to + # make sure that the __str__() doesn't fall apart when None is + # passed instead of an integer line and column number + # + # use "normal" values for the locator: + str(SAXParseException("message", None, + DummyLocator(1, 1))) + # use None for the line number: + str(SAXParseException("message", None, + DummyLocator(None, 1))) + # use None for the column number: + str(SAXParseException("message", None, + DummyLocator(1, None))) + # use None for both: + str(SAXParseException("message", None, + DummyLocator(None, None))) + return 1 + +class DummyLocator: + def __init__(self, lineno, colno): + self._lineno = lineno + self._colno = colno + + def getPublicId(self): + return "pubid" + + def getSystemId(self): + return "sysid" + + def getLineNumber(self): + return self._lineno + + def getColumnNumber(self): + return self._colno # =========================================================================== # |