Skip to content

Element.extend hides exceptions from underlying generators. #123213

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

Closed
bharel opened this issue Aug 22, 2024 · 2 comments
Closed

Element.extend hides exceptions from underlying generators. #123213

bharel opened this issue Aug 22, 2024 · 2 comments
Labels
topic-XML type-bug An unexpected behavior, bug, or error

Comments

@bharel
Copy link
Contributor

bharel commented Aug 22, 2024

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

@bharel bharel added the type-bug An unexpected behavior, bug, or error label Aug 22, 2024
@bharel
Copy link
Contributor Author

bharel commented Aug 22, 2024

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...

@bharel bharel changed the title ElementTree.extend hides exceptions from underlying generators. Element.extend hides exceptions from underlying generators. Aug 22, 2024
serhiy-storchaka pushed a commit that referenced this issue Aug 23, 2024
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Aug 23, 2024
…nment to no longer hide exceptions (pythonGH-123214)

(cherry picked from commit 90b6d0e)

Co-authored-by: Bar Harel <[email protected]>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Aug 23, 2024
…nment to no longer hide exceptions (pythonGH-123214)

(cherry picked from commit 90b6d0e)

Co-authored-by: Bar Harel <[email protected]>
@bharel
Copy link
Contributor Author

bharel commented Aug 23, 2024

Fixed 🎉

@bharel bharel closed this as completed Aug 23, 2024
Yhg1s pushed a commit that referenced this issue Sep 2, 2024
…gnment to no longer hide exceptions (GH-123214) (#123257)

gh-123213: Fixed xml.etree.ElementTree.Element.extend and assignment to no longer hide exceptions (GH-123214)
(cherry picked from commit 90b6d0e)

Co-authored-by: Bar Harel <[email protected]>
hugovk pushed a commit that referenced this issue Sep 6, 2024
…gnment to no longer hide exceptions (GH-123214) (#123258)

Co-authored-by: Bar Harel <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic-XML type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants