mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
Issue #9708: Fix support for iterparse(parser=...) argument per documentation.
When _elementtree is imported, iterparse is redefined as a class and the parser argument was ommitted. Fix this, and add a docstring to the class.
This commit is contained in:
parent
33f7cdd975
commit
aaa9780fe1
2 changed files with 22 additions and 3 deletions
|
@ -1881,6 +1881,12 @@ class ElementIterTest(unittest.TestCase):
|
|||
sourcefile = serialize(doc, to_string=False)
|
||||
self.assertEqual(next(ET.iterparse(sourcefile))[0], 'end')
|
||||
|
||||
# With an explitit parser too (issue #9708)
|
||||
sourcefile = serialize(doc, to_string=False)
|
||||
parser = ET.XMLParser(target=ET.TreeBuilder())
|
||||
self.assertEqual(next(ET.iterparse(sourcefile, parser=parser))[0],
|
||||
'end')
|
||||
|
||||
tree = ET.ElementTree(None)
|
||||
self.assertRaises(AttributeError, tree.iter)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue