Skip to content

Element.extend hides exceptions from underlying generators. #123213

Closed

Description

@bharel

Bug report

Bug description:

>>> from xml.etree.ElementTree import Element
>>> Element("a").extend(Element("a") for i in range(10)) # works
>>> Element("a").extend(1/0 for i in range(10)) # throws unrelated TypeError
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: expected sequence, not "generator"

C-implementation only bug.

Submitting a patch...

CPython versions tested on:

3.12, 3.13, CPython main branch

Operating systems tested on:

macOS, Windows

Linked PRs

Activity

  1. added
    type-bugAn unexpected behavior, bug, or error
    on Aug 22, 2024
  2. bharel commented on Aug 22, 2024

    @bharel
    ContributorAuthor

    Also happens on assignment:

    >>> Element("a")[:1] = (1/0 for i in range(1))
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    TypeError: expected sequence, not "generator"

    Patching up...

  3. changed the title [-]ElementTree.extend hides exceptions from underlying generators.[/-] [+]Element.extend hides exceptions from underlying generators.[/+] on Aug 22, 2024
  4. added a commit that references this issue on Aug 23, 2024
  5. added 2 commits that reference this issue on Aug 23, 2024
  6. bharel commented on Aug 23, 2024

    @bharel
    ContributorAuthor

    Fixed 🎉

  7. added a commit that references this issue on Sep 2, 2024
  8. added a commit that references this issue on Sep 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic-XMLtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions