mirror of
https://github.com/python/cpython.git
synced 2025-10-17 12:18:23 +00:00
Issue #6676: Ensure a meaningful exception is raised when attempting
to parse more than one XML document per pyexpat xmlparser instance. (Original patches by Hirokazu Yamamoto and Amaury Forgeot d'Arc, with suggested wording by David Gutteridge)
This commit is contained in:
parent
2542b66bb0
commit
e7d532fbc9
4 changed files with 26 additions and 2 deletions
|
@ -236,6 +236,18 @@ class ParseTest(unittest.TestCase):
|
|||
operations = out.out
|
||||
self._verify_parse_output(operations)
|
||||
|
||||
def test_parse_again(self):
|
||||
parser = expat.ParserCreate()
|
||||
file = BytesIO(data)
|
||||
parser.ParseFile(file)
|
||||
# Issue 6676: ensure a meaningful exception is raised when attempting
|
||||
# to parse more than one XML document per xmlparser instance,
|
||||
# a limitation of the Expat library.
|
||||
with self.assertRaises(expat.error) as cm:
|
||||
parser.ParseFile(file)
|
||||
self.assertEqual(expat.ErrorString(cm.exception.code),
|
||||
expat.errors.XML_ERROR_FINISHED)
|
||||
|
||||
class NamespaceSeparatorTest(unittest.TestCase):
|
||||
def test_legal(self):
|
||||
# Tests that make sure we get errors when the namespace_separator value
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue