New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ElementTree: Element.getiterator(tag) broken in 3.6 #72501
Comments
The documentation says that getiterator() still accepts a tag argument, but it does not: >>> from xml.etree.ElementTree import Element
>>> el = Element('foo')
>>> el.getiterator('bar')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
SystemError: ../Python/getargs.c:1508: bad argument to internal function
>>> el.getiterator(tag='bar')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: iter() takes at most 1 argument (140172072006928 given) This is with Python 3.6.0 beta 1 on Debian GNU/Linux amd64. |
Even better: Python 3.6.0b1 (v3.6.0b1:5b0ca4ed5e2f, Sep 12 2016, 09:24:46)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from xml.etree.ElementTree import Element
>>> el = Element('foo')
>>> el.getiterator('bar')
Segmentation fault: 11 |
The bug seems related to the new FASTCALL calling convention introduced in Python 3.6b1. For an unknown reason, the METH_FASTCALL defined in Modules/clinic/_elementtree.c on _elementtree_Element_iter() seems to be ignored or lost somewhere? |
Oh... Modules/_elementtree.c uses a function defined in Modules/clinic/_elementtree.c. It hardcodes flags, whereas flags changed. Maybe the alias should be created differently to avoid such issue in the future? Moreover, obviously, we lack unit tests on this getiterator() method. |
New changeset 1e29dca5dc4c by Victor Stinner in branch '3.6': |
I pushed the first obvious fix to unblock the 3.6 beta 2 release scheduled for next monday. |
Here is a test. |
New changeset ca1b91829edf by Serhiy Storchaka in branch '3.5': New changeset c14a2d2a3b19 by Serhiy Storchaka in branch '3.6': New changeset 17334c1d9245 by Serhiy Storchaka in branch 'default': |
Misc/NEWS
so that it is managed by towncrier #552Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: