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

Raise SystemError on programmical errors in PyArg_Parse*() #70500

Closed
serhiy-storchaka opened this issue Feb 8, 2016 · 8 comments
Closed

Raise SystemError on programmical errors in PyArg_Parse*() #70500

serhiy-storchaka opened this issue Feb 8, 2016 · 8 comments
Assignees
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement

Comments

@serhiy-storchaka
Copy link
Member

BPO 26312
Nosy @vstinner, @vadmium, @JimJJewett, @serhiy-storchaka
Files
  • pyarg_parse_error.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 = 'https://github.com/serhiy-storchaka'
    closed_at = <Date 2016-02-11.11:33:18.682>
    created_at = <Date 2016-02-08.19:39:33.798>
    labels = ['interpreter-core', 'type-feature']
    title = 'Raise SystemError on programmical errors in PyArg_Parse*()'
    updated_at = <Date 2016-02-11.11:33:18.681>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2016-02-11.11:33:18.681>
    actor = 'serhiy.storchaka'
    assignee = 'serhiy.storchaka'
    closed = True
    closed_date = <Date 2016-02-11.11:33:18.682>
    closer = 'serhiy.storchaka'
    components = ['Interpreter Core']
    creation = <Date 2016-02-08.19:39:33.798>
    creator = 'serhiy.storchaka'
    dependencies = []
    files = ['41859']
    hgrepos = []
    issue_num = 26312
    keywords = ['patch']
    message_count = 8.0
    messages = ['259877', '259916', '260049', '260059', '260064', '260083', '260084', '260090']
    nosy_count = 5.0
    nosy_names = ['vstinner', 'python-dev', 'martin.panter', 'Jim.Jewett', 'serhiy.storchaka']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue26312'
    versions = ['Python 3.6']

    @serhiy-storchaka
    Copy link
    Member Author

    For now programmical errors with the use of PyArg_ParseTuple() cause raising SystemError. But some programmical errors with the use of PyArg_ParseTupleAndKeywords() cause raising RuntimeError. I think that SystemError is the correct exception type.

    Proposed patch replaces RuntimeError with SystemError in PyArg_ParseTupleAndKeywords(). This change shouldn't break any code (except CPython tests for PyArg_ParseTupleAndKeywords()), because this exception never raised if PyArg_Parse*() functions are used correctly.

    @serhiy-storchaka serhiy-storchaka added interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement labels Feb 8, 2016
    @vadmium
    Copy link
    Member

    vadmium commented Feb 9, 2016

    Seems like a reasonable change and patch to me.

    @vstinner
    Copy link
    Member

    Yeah, I also expect SystemError from C functions (of the Python C API) badly used.

    RuntimeError is more used in programming bugs at Python level.

    pyarg_parse_error.patch LGTM.

    @jimjjewett
    Copy link
    Mannequin

    jimjjewett mannequin commented Feb 10, 2016

    It feels a bit odd to say that I've performed a triage review given the three people already involved -- but I did, and I think it is ready to commit.

    I believe it is a bug fix, but too subtle a bug to justify backporting.

    The only question is whether there should be a "What's New?" entry for the change.

    @vstinner
    Copy link
    Member

    The only question is whether there should be a "What's New?" entry for the change.

    I don't think so. It's low level and nobody should see this exception anyway :-) It's an obvious bug in a C extension.

    @serhiy-storchaka
    Copy link
    Member Author

    SystemError is not new exception. It could be raised on other programming bugs. In any case I doesn't expect that anybody catches such exceptions.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Feb 11, 2016

    New changeset c7eff18f3840 by Serhiy Storchaka in branch 'default':
    Issue bpo-26312: SystemError is now raised in all programming bugs with using
    https://hg.python.org/cpython/rev/c7eff18f3840

    @serhiy-storchaka
    Copy link
    Member Author

    Thanks for your review.

    @serhiy-storchaka serhiy-storchaka self-assigned this Feb 11, 2016
    @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
    interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants