This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2010年08月28日 21:51 by adrian_nye, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| issue9708.Python330a0.patch | Shugyousha, 2011年11月25日 15:22 | Simple patch in c module glue code | review | |
| Messages (10) | |||
|---|---|---|---|
| msg115173 - (view) | Author: Adrian Nye (adrian_nye) | Date: 2010年08月28日 21:51 | |
The (python) ElementTree library began in 2.7 to support the "parser" argument, but cElementTree does not support it. Either cElementTree should support it, or the documentation should mention that it does not. |
|||
| msg146596 - (view) | Author: Florent Xicluna (flox) * (Python committer) | Date: 2011年10月29日 03:07 | |
Documentation should be fixed for 3.2 and 2.7. Patch welcomed. |
|||
| msg148324 - (view) | Author: Silvan Jegen (Shugyousha) | Date: 2011年11月25日 15:22 | |
I changed a few lines in the glue code of the _elementtree.c Module of Python 3.3.0a0 to add support for the "parser" argument. I do have to admit though that I am not familiar with the Python/C-API so this solution may not be ideal (i. e. it may be falling back to the Python implementation of iterparse without me realizing). Please note that it is not possible to give an ElementTree.XMLParser instance as a parameter to the cElementTree.iterparse function (which may not be desirable in any case) using this patch. I assume that the patch will be applicable to Python 2.7.x as well, but I did not try it. I can apply/adapt it to Python 2.7.x, if you think that would be useful. |
|||
| msg166042 - (view) | Author: Florent Xicluna (flox) * (Python committer) | Date: 2012年07月21日 15:23 | |
Either the documentation or the implementation should be fixed in 3.3, because they do not match. |
|||
| msg180387 - (view) | Author: Eli Bendersky (eli.bendersky) * (Python committer) | Date: 2013年01月22日 13:52 | |
Could you point out specifically which methods in ET don't work with the argument, and describe the problem in general? |
|||
| msg180421 - (view) | Author: Silvan Jegen (Shugyousha) | Date: 2013年01月22日 19:02 | |
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.
|
|||
| msg180527 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2013年01月24日 15:17 | |
New changeset cce526a28f81 by Eli Bendersky in branch '3.3': Issue #9708: Fix support for iterparse(parser=...) argument per documentation. http://hg.python.org/cpython/rev/cce526a28f81 New changeset 0c9268ac3ffa by Eli Bendersky in branch 'default': Issue #9708: Fix support for iterparse(parser=...) argument per documentation. http://hg.python.org/cpython/rev/0c9268ac3ffa |
|||
| msg180528 - (view) | Author: Eli Bendersky (eli.bendersky) * (Python committer) | Date: 2013年01月24日 15:19 | |
Support added in 3.3 and default Documentation patches should be done for 2.7 and 3.2 |
|||
| msg180529 - (view) | Author: Eli Bendersky (eli.bendersky) * (Python committer) | Date: 2013年01月24日 15:26 | |
Fix to 3.2 committed in 5b02d622d625 |
|||
| msg180531 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2013年01月24日 15:28 | |
New changeset 8f2edea69d5d by Eli Bendersky in branch '2.7': Issue #9708: clarify doc of iterparse - cElementTree doesn't support the parser argument http://hg.python.org/cpython/rev/8f2edea69d5d |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:05 | admin | set | github: 53917 |
| 2013年01月24日 15:29:16 | eli.bendersky | set | status: open -> closed resolution: fixed stage: needs patch -> resolved |
| 2013年01月24日 15:28:46 | python-dev | set | messages: + msg180531 |
| 2013年01月24日 15:26:23 | eli.bendersky | set | messages: + msg180529 |
| 2013年01月24日 15:19:56 | eli.bendersky | set | messages: + msg180528 |
| 2013年01月24日 15:17:44 | python-dev | set | nosy:
+ python-dev messages: + msg180527 |
| 2013年01月22日 19:02:47 | Shugyousha | set | messages: + msg180421 |
| 2013年01月22日 13:52:11 | eli.bendersky | set | messages: + msg180387 |
| 2013年01月22日 12:54:43 | ezio.melotti | set | nosy:
+ ezio.melotti versions: + Python 3.4 |
| 2012年07月21日 15:23:37 | flox | set | nosy:
+ eli.bendersky messages: + msg166042 versions: + Python 3.3 |
| 2011年11月25日 15:22:08 | Shugyousha | set | files:
+ issue9708.Python330a0.patch nosy: + Shugyousha messages: + msg148324 keywords: + patch |
| 2011年10月29日 03:07:06 | flox | set | nosy:
+ docs@python messages: + msg146596 assignee: docs@python components: + Documentation stage: test needed -> needs patch |
| 2010年09月03日 17:00:04 | flox | set | nosy:
+ effbot stage: test needed type: behavior versions: + Python 3.2 |
| 2010年08月28日 23:53:21 | r.david.murray | set | nosy:
+ flox |
| 2010年08月28日 21:51:34 | adrian_nye | create | |