classification
Title: ElementTree: Element.getiterator(tag) broken in 3.6
Type: crash Stage: resolved
Components: Library (Lib) Versions: Python 3.7, Python 3.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: mitya57, ned.deily, python-dev, serhiy.storchaka, vstinner
Priority: Keywords: patch

Created on 2016-09-29 19:44 by mitya57, last changed 2017-03-31 16:36 by dstufft. This issue is now closed.

Files
File name Uploaded Description Edit
etree.patch vstinner, 2016-09-29 20:05 review
test_getiterator.patch serhiy.storchaka, 2016-09-29 20:29 review
Pull Requests
URL Status Linked Edit
PR 552 closed dstufft, 2017-03-31 16:36
Messages (8)
msg277717 - (view) Author: Dmitry Shachnev (mitya57) * Date: 2016-09-29 19:44
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.
msg277719 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2016-09-29 19:51
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
msg277721 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2016-09-29 19:59
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?
msg277722 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2016-09-29 20:05
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.
msg277723 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-09-29 20:14
New changeset 1e29dca5dc4c by Victor Stinner in branch '3.6':
Fix xml.etree.ElementTree.Element.getiterator()
https://hg.python.org/cpython/rev/1e29dca5dc4c
msg277724 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2016-09-29 20:16
I pushed the first obvious fix to unblock the 3.6 beta 2 release scheduled for next monday.
msg277725 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-09-29 20:29
Here is a test.
msg279370 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-10-25 07:38
New changeset ca1b91829edf by Serhiy Storchaka in branch '3.5':
Issue #28314: Added tests for xml.etree.ElementTree.Element.getiterator().
https://hg.python.org/cpython/rev/ca1b91829edf

New changeset c14a2d2a3b19 by Serhiy Storchaka in branch '3.6':
Issue #28314: Added tests for xml.etree.ElementTree.Element.getiterator().
https://hg.python.org/cpython/rev/c14a2d2a3b19

New changeset 17334c1d9245 by Serhiy Storchaka in branch 'default':
Issue #28314: Added tests for xml.etree.ElementTree.Element.getiterator().
https://hg.python.org/cpython/rev/17334c1d9245
History
Date User Action Args
2017-03-31 16:36:26dstufftsetpull_requests: + pull_request1004
2016-10-25 07:38:56serhiy.storchakasetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2016-10-25 07:38:24python-devsetmessages: + msg279370
2016-10-10 19:08:50ned.deilysetstage: needs patch -> patch review
2016-09-29 20:29:55serhiy.storchakasetfiles: + test_getiterator.patch

messages: + msg277725
2016-09-29 20:16:20vstinnersetpriority: release blocker ->

messages: + msg277724
2016-09-29 20:14:46python-devsetnosy: + python-dev
messages: + msg277723
2016-09-29 20:14:08serhiy.storchakasetnosy: + serhiy.storchaka
2016-09-29 20:07:47vstinnersetpriority: critical -> release blocker
2016-09-29 20:05:45vstinnersetfiles: + etree.patch
keywords: + patch
messages: + msg277722
2016-09-29 19:59:48vstinnersetnosy: + vstinner
messages: + msg277721
2016-09-29 19:51:05ned.deilysetpriority: normal -> critical

type: behavior -> crash
versions: + Python 3.7
nosy: + ned.deily

messages: + msg277719
stage: needs patch
2016-09-29 19:44:06mitya57create