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:
Eli Bendersky 2013-01-24 07:15:19 -08:00
parent 33f7cdd975
commit aaa9780fe1
2 changed files with 22 additions and 3 deletions

View file

@ -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)