Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • pypy pypy
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 675
    • Issues 675
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 13
    • Merge requests 13
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Container Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • PyPyPyPy
  • pypypypy
  • Issues
  • #3181
Closed
Open
Issue created Mar 03, 2020 by Alex Prengère@alexprengereDeveloper

xml.etree.ElementTree.extend does not work with iterators on Pypy3 (Pypy2 is fine)

xml.etree.ElementTree.extend works well with lists on Pypy2/Pypy3, but when passing an iterator, there is a difference, and it is Pypy2 that behaves like Cpython2.7/3.x.

Pypy2 and Cpython:

>>>> from xml.etree.ElementTree import Element
>>>> r = Element("root")
>>>> r.extend((Element(str(i)) for i in range(3)))
>>>> print(list(r))
[<Element '0' at 0x...>, <Element '1' at 0x...>, <Element '2' at 0x...>]

On Pypy3 7.3:

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

Looking at what changed in lib-python/xx/xml/etree/ElementTree.py between Pypy2/Pypy3, there is an additional _assert_is_element that may be responsible for emptying the iterator.

class Element:
    ...
    def extend(self, elements):
        """Append subelements from a sequence.

        *elements* is a sequence with zero or more elements.

        """
  +++   for element in elements:
  +++       self._assert_is_element(element)
        self._children.extend(elements)
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking