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

ElementTree: Element.getiterator(tag) broken in 3.6 #72501

Closed
mitya57 mannequin opened this issue Sep 29, 2016 · 8 comments
Closed

ElementTree: Element.getiterator(tag) broken in 3.6 #72501

mitya57 mannequin opened this issue Sep 29, 2016 · 8 comments
Labels
3.7 (EOL) end of life stdlib Python modules in the Lib dir type-crash A hard crash of the interpreter, possibly with a core dump

Comments

@mitya57
Copy link
Mannequin

mitya57 mannequin commented Sep 29, 2016

BPO 28314
Nosy @vstinner, @ned-deily, @serhiy-storchaka, @mitya57
PRs
  • [Do Not Merge] Convert Misc/NEWS so that it is managed by towncrier #552
  • Files
  • etree.patch
  • test_getiterator.patch
  • 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 2016-10-25.07:38:56.161>
    created_at = <Date 2016-09-29.19:44:06.336>
    labels = ['3.7', 'library', 'type-crash']
    title = 'ElementTree: Element.getiterator(tag) broken in 3.6'
    updated_at = <Date 2017-03-31.16:36:26.838>
    user = 'https://github.com/mitya57'

    bugs.python.org fields:

    activity = <Date 2017-03-31.16:36:26.838>
    actor = 'dstufft'
    assignee = 'none'
    closed = True
    closed_date = <Date 2016-10-25.07:38:56.161>
    closer = 'serhiy.storchaka'
    components = ['Library (Lib)']
    creation = <Date 2016-09-29.19:44:06.336>
    creator = 'mitya57'
    dependencies = []
    files = ['44881', '44882']
    hgrepos = []
    issue_num = 28314
    keywords = ['patch']
    message_count = 8.0
    messages = ['277717', '277719', '277721', '277722', '277723', '277724', '277725', '279370']
    nosy_count = 5.0
    nosy_names = ['vstinner', 'ned.deily', 'python-dev', 'serhiy.storchaka', 'mitya57']
    pr_nums = ['552']
    priority = None
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'crash'
    url = 'https://bugs.python.org/issue28314'
    versions = ['Python 3.6', 'Python 3.7']

    @mitya57
    Copy link
    Mannequin Author

    mitya57 mannequin commented Sep 29, 2016

    The documentation says that getiterator() still accepts a tag argument, but it does not:

    >>> from xml.etree.ElementTree import Element
    >>> el = Element('foo')
    >>> el.getiterator('bar')
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    SystemError: ../Python/getargs.c:1508: bad argument to internal function
    >>> el.getiterator(tag='bar')
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    TypeError: iter() takes at most 1 argument (140172072006928 given)

    This is with Python 3.6.0 beta 1 on Debian GNU/Linux amd64.

    @mitya57 mitya57 mannequin added type-bug An unexpected behavior, bug, or error stdlib Python modules in the Lib dir labels Sep 29, 2016
    @ned-deily
    Copy link
    Member

    Even better:

    Python 3.6.0b1 (v3.6.0b1:5b0ca4ed5e2f, Sep 12 2016, 09:24:46)
    [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    >>> from xml.etree.ElementTree import Element
    >>> el = Element('foo')
    >>> el.getiterator('bar')
    Segmentation fault: 11

    @ned-deily ned-deily added 3.7 (EOL) end of life type-crash A hard crash of the interpreter, possibly with a core dump and removed type-bug An unexpected behavior, bug, or error labels Sep 29, 2016
    @vstinner
    Copy link
    Member

    The bug seems related to the new FASTCALL calling convention introduced in Python 3.6b1. For an unknown reason, the METH_FASTCALL defined in Modules/clinic/_elementtree.c on _elementtree_Element_iter() seems to be ignored or lost somewhere?

    @vstinner
    Copy link
    Member

    Oh... Modules/_elementtree.c uses a function defined in Modules/clinic/_elementtree.c. It hardcodes flags, whereas flags changed.

    Maybe the alias should be created differently to avoid such issue in the future?

    Moreover, obviously, we lack unit tests on this getiterator() method.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Sep 29, 2016

    New changeset 1e29dca5dc4c by Victor Stinner in branch '3.6':
    Fix xml.etree.ElementTree.Element.getiterator()
    https://hg.python.org/cpython/rev/1e29dca5dc4c

    @vstinner
    Copy link
    Member

    I pushed the first obvious fix to unblock the 3.6 beta 2 release scheduled for next monday.

    @serhiy-storchaka
    Copy link
    Member

    Here is a test.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Oct 25, 2016

    New changeset ca1b91829edf by Serhiy Storchaka in branch '3.5':
    Issue bpo-28314: Added tests for xml.etree.ElementTree.Element.getiterator().
    https://hg.python.org/cpython/rev/ca1b91829edf

    New changeset c14a2d2a3b19 by Serhiy Storchaka in branch '3.6':
    Issue bpo-28314: Added tests for xml.etree.ElementTree.Element.getiterator().
    https://hg.python.org/cpython/rev/c14a2d2a3b19

    New changeset 17334c1d9245 by Serhiy Storchaka in branch 'default':
    Issue bpo-28314: Added tests for xml.etree.ElementTree.Element.getiterator().
    https://hg.python.org/cpython/rev/17334c1d9245

    @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.7 (EOL) end of life stdlib Python modules in the Lib dir type-crash A hard crash of the interpreter, possibly with a core dump
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants