Skip to content
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

xml.etree.ElementTree.extend does not work with iterators when using the Python implementation #87565

Closed
alexprengere mannequin opened this issue Mar 4, 2021 · 9 comments
Labels
3.8 only security fixes 3.9 only security fixes 3.10 only security fixes topic-XML type-bug An unexpected behavior, bug, or error

Comments

@alexprengere
Copy link
Mannequin

alexprengere mannequin commented Mar 4, 2021

BPO 43399
Nosy @rhettinger, @scoder, @ambv, @serhiy-storchaka, @miss-islington, @alexprengere
PRs
  • bpo-43399: Fix ElementTree.extend not working on iterators #24751
  • [3.8] bpo-43399: Fix ElementTree.extend not working on iterators (GH-24751) #25101
  • [3.9] bpo-43399: Fix ElementTree.extend not working on iterators (GH-24751) #25102
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2021-11-24.08:57:50.445>
    created_at = <Date 2021-03-04.15:59:21.733>
    labels = ['expert-XML', 'type-bug', '3.8', '3.9', '3.10']
    title = 'xml.etree.ElementTree.extend does not work with iterators when using the Python implementation'
    updated_at = <Date 2021-11-24.08:57:50.445>
    user = 'https://github.com/alexprengere'

    bugs.python.org fields:

    activity = <Date 2021-11-24.08:57:50.445>
    actor = 'alexprengere'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-11-24.08:57:50.445>
    closer = 'alexprengere'
    components = ['XML']
    creation = <Date 2021-03-04.15:59:21.733>
    creator = 'alexprengere'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 43399
    keywords = ['patch']
    message_count = 9.0
    messages = ['388099', '388118', '388119', '388137', '389830', '389853', '389856', '389857', '389858']
    nosy_count = 7.0
    nosy_names = ['rhettinger', 'scoder', 'eli.bendersky', 'lukasz.langa', 'serhiy.storchaka', 'miss-islington', 'alexprengere']
    pr_nums = ['24751', '25101', '25102']
    priority = 'normal'
    resolution = None
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue43399'
    versions = ['Python 3.8', 'Python 3.9', 'Python 3.10']

    @alexprengere
    Copy link
    Mannequin Author

    alexprengere mannequin commented Mar 4, 2021

    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.

    @alexprengere alexprengere mannequin added 3.7 (EOL) end of life 3.10 only security fixes 3.8 only security fixes 3.9 only security fixes topic-XML type-bug An unexpected behavior, bug, or error labels Mar 4, 2021
    @serhiy-storchaka
    Copy link
    Member

    Your proposed fix LGTM. Please open a PR. Don't forget about test and NEWS entry.

    @scoder
    Copy link
    Contributor

    scoder commented Mar 4, 2021

    Thanks for the report and the PR. I would argue that this can still be fixed in Py3.8, given the low impact (but not earlier). The behaviour is clearly wrong (in a subtle way) and most users won't notice it because they won't switch off the C accelerator module.

    @scoder scoder removed 3.7 (EOL) end of life labels Mar 4, 2021
    @rhettinger
    Copy link
    Contributor

    +1 for back porting, but check with the RM first.

    @alexprengere
    Copy link
    Mannequin Author

    alexprengere mannequin commented Mar 30, 2021

    Is there anything else I should be doing, in order to get this merged in time for 3.10? (the PR is "awaiting merge")
    For the record, the equivalent PR for PyPy is now merged in the py3.7 branch: https://foss.heptapod.net/pypy/pypy/-/merge_requests/807.

    Regarding the backporting, I understand from the devguide this is done automatically from GitHub labels (nice!), but it does not look like I have the rights to add those to my PR.

    @serhiy-storchaka
    Copy link
    Member

    New changeset 51a85dd by Alex Prengère in branch 'master':
    bpo-43399: Fix ElementTree.extend not working on iterators (GH-24751)
    51a85dd

    @serhiy-storchaka
    Copy link
    Member

    Pinging us was the only action needed. Thank you for your contribution Alex.

    @miss-islington
    Copy link
    Contributor

    New changeset c1079cd by Miss Islington (bot) in branch '3.8':
    bpo-43399: Fix ElementTree.extend not working on iterators (GH-24751)
    c1079cd

    @miss-islington
    Copy link
    Contributor

    New changeset b500bd8 by Miss Islington (bot) in branch '3.9':
    bpo-43399: Fix ElementTree.extend not working on iterators (GH-24751)
    b500bd8

    @alexprengere alexprengere mannequin closed this as completed Nov 24, 2021
    @alexprengere alexprengere mannequin closed this as completed Nov 24, 2021
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.8 only security fixes 3.9 only security fixes 3.10 only security fixes topic-XML type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    4 participants