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

Propagate all errors from ElementTree.iterparse #70000

Closed
serhiy-storchaka opened this issue Dec 6, 2015 · 3 comments
Closed

Propagate all errors from ElementTree.iterparse #70000

serhiy-storchaka opened this issue Dec 6, 2015 · 3 comments
Labels
extension-modules C modules in the Modules dir topic-XML type-bug An unexpected behavior, bug, or error

Comments

@serhiy-storchaka
Copy link
Member

BPO 25814
Nosy @brettcannon, @scoder, @vadmium, @serhiy-storchaka
Files
  • etree_propagate_errors.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 2015-12-07.00:32:44.462>
    created_at = <Date 2015-12-06.15:00:03.051>
    labels = ['extension-modules', 'expert-XML', 'type-bug']
    title = 'Propagate all errors from ElementTree.iterparse'
    updated_at = <Date 2015-12-07.00:32:44.461>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2015-12-07.00:32:44.461>
    actor = 'serhiy.storchaka'
    assignee = 'none'
    closed = True
    closed_date = <Date 2015-12-07.00:32:44.462>
    closer = 'serhiy.storchaka'
    components = ['Extension Modules', 'XML']
    creation = <Date 2015-12-06.15:00:03.051>
    creator = 'serhiy.storchaka'
    dependencies = []
    files = ['41256']
    hgrepos = []
    issue_num = 25814
    keywords = ['patch']
    message_count = 3.0
    messages = ['256012', '256031', '256035']
    nosy_count = 5.0
    nosy_names = ['brett.cannon', 'scoder', 'python-dev', 'martin.panter', 'serhiy.storchaka']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue25814'
    versions = ['Python 2.7', 'Python 3.4', 'Python 3.5', 'Python 3.6']

    @serhiy-storchaka
    Copy link
    Member Author

    Some memory errors raised in handlers during XML parsing are explicitly or implicitly propagated to the caller of XMLParser methods feed(), close(), and _parse_whole(). But others are silenced with PyErr_Clear() with added comments "FIXME: propagate error". There are no reasons why one errors are propagated and others are not. For example memory error during creating tuple is not propagated, but memory error during resizing a list to which this tuple is appended is propagated. Looks as this is not intentional.

    Not propagated errors can cause the lost of events. Proposed patch makes the parser to propagate all errors. Since it extracts common code into the treebuilder_append_event() function and inlines the treebuilder_handle_namespace() function, the resulting code becomes even simpler, its size is decreased by 49 lines.

    @serhiy-storchaka serhiy-storchaka added extension-modules C modules in the Modules dir topic-XML type-bug An unexpected behavior, bug, or error labels Dec 6, 2015
    @vadmium
    Copy link
    Member

    vadmium commented Dec 6, 2015

    The patch looks good as far as I can tell. I left a question about an inconsistency with checking for a null pointer.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Dec 6, 2015

    New changeset 2df330606cd0 by Serhiy Storchaka in branch '3.4':
    bpo-25814: Propagate all errors from custom XML parser handlers
    https://hg.python.org/cpython/rev/2df330606cd0

    New changeset de9ef294a3ef by Serhiy Storchaka in branch '2.7':
    bpo-25814: Propagate all errors from custom XML parser handlers
    https://hg.python.org/cpython/rev/de9ef294a3ef

    New changeset 0d1bbfe8fd09 by Serhiy Storchaka in branch '3.5':
    bpo-25814: Propagate all errors from custom XML parser handlers
    https://hg.python.org/cpython/rev/0d1bbfe8fd09

    New changeset 2cf16918b632 by Serhiy Storchaka in branch 'default':
    bpo-25814: Propagate all errors from custom XML parser handlers
    https://hg.python.org/cpython/rev/2cf16918b632

    @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
    extension-modules C modules in the Modules dir topic-XML type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants