Author Shugyousha
Recipients Shugyousha, adrian_nye, docs@python, effbot, eli.bendersky, ezio.melotti, flox
Date 2013-01-22.19:02:47
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1358881367.33.0.406004506317.issue9708@psf.upfronthosting.co.za>
In-reply-to
Content
The situation is as follows.

According to the online documentation of Python 2.7 the
xml.etree.ElementTree.iterparse() function takes up to three arguments, two of them named ones:

    xml.etree.ElementTree.iterparse(source, events=None, parser=None)

In the C implementation of the function however, the "parser" argument does not seem to be supported:


    >>> import xml.etree.ElementTree as ET
    >>> import xml.etree.cElementTree as ETc # C version of the library 
    >>> result = ET.iterparse("xmltest.xml", None, ET.XMLParser()) # Works
    >>>

    >>> result = ETc.iterparse("xmltest.xml", None, ET.XMLParser()) # C version does'nt
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    TypeError: __init__() takes at most 3 arguments (4 given)

The documentation does not mention the C version of the function not taking the "parser" argument as far as I know.

Additionally, the xml.etree.ElementTree.iterparse() online documentation
for Python 3.3 mentions the "parser" argument as well. When using this
argument however, Python throws an error:


    Python 3.3.0 (default, Dec 22 2012, 21:02:07) 
    [GCC 4.7.2] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import xml.etree.ElementTree as ET
    >>> ET.iterparse("xmltest.xml", None, ET.XMLParser())
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    TypeError: __init__() takes from 2 to 3 positional arguments but 4 were given


A look at the pydoc output for xml.etree.ElementTree actually does not mention a named "parser" argument to iterparse() at all (Please note that iterparse seems to be a constructor in Python 3.3):

class iterparse(builtins.object)
     |  Methods defined here:
     |  
     |  __init__(self, file, events=None)


In these cases either the implementation or the documentation should be
changed.

Please feel free to ask away if you have more questions.
History
Date User Action Args
2013-01-22 19:02:47Shugyoushasetrecipients: + Shugyousha, effbot, ezio.melotti, eli.bendersky, flox, docs@python, adrian_nye
2013-01-22 19:02:47Shugyoushasetmessageid: <1358881367.33.0.406004506317.issue9708@psf.upfronthosting.co.za>
2013-01-22 19:02:47Shugyoushalinkissue9708 messages
2013-01-22 19:02:47Shugyoushacreate