[New-bugs-announce] [issue43399] xml.etree.ElementTree.extend does not work with iterators when using the Python implementation

Alex report at bugs.python.org
Thu Mar 4 10:59:21 EST 2021


New submission from Alex <alexprengere at gmail.com>:

This issue is only visible when the C accelerator of ElementTree is *not* used. It is the counterpart of the following issue on PyPy3: https://foss.heptapod.net/pypy/pypy/-/issues/3181

 >>> from xml.etree.ElementTree import Element
 >>> r = Element("root")
 >>> r.extend((Element(str(i)) for i in range(3)))
 >>> print(list(r))
 []

When using the C accelerator, the list is not empty, as expected. In the Python code, a check on the input empties the input iterator.

The fix is trivial (one-line change), so if you are interested I could open a PR, which would be my first, so a good occasion to go through the devguide ;)
I understand that since Python3.3 the C accelerator is used by default, so I would agree that this is not really a bug, and I can just fix it on PyPy side.

----------
components: XML
messages: 388099
nosy: alexprengere
priority: normal
severity: normal
status: open
title: xml.etree.ElementTree.extend does not work with iterators when using the Python implementation
type: behavior
versions: Python 3.10, Python 3.6, Python 3.7, Python 3.8, Python 3.9

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue43399>
_______________________________________


More information about the New-bugs-announce mailing list