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

refleak on SyntaxError in function parameter annotation #68875

Closed
1st1 opened this issue Jul 22, 2015 · 6 comments
Closed

refleak on SyntaxError in function parameter annotation #68875

1st1 opened this issue Jul 22, 2015 · 6 comments
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs)

Comments

@1st1
Copy link
Member

1st1 commented Jul 22, 2015

BPO 24687
Nosy @ncoghlan, @benjaminp, @1st1
Files
  • compile.patch
  • compile2.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-07-23.06:15:17.562>
    created_at = <Date 2015-07-22.22:09:17.595>
    labels = ['interpreter-core']
    title = 'refleak on SyntaxError in function parameter annotation'
    updated_at = <Date 2015-07-23.06:15:17.562>
    user = 'https://github.com/1st1'

    bugs.python.org fields:

    activity = <Date 2015-07-23.06:15:17.562>
    actor = 'yselivanov'
    assignee = 'none'
    closed = True
    closed_date = <Date 2015-07-23.06:15:17.562>
    closer = 'yselivanov'
    components = ['Interpreter Core']
    creation = <Date 2015-07-22.22:09:17.595>
    creator = 'yselivanov'
    dependencies = []
    files = ['39985', '39990']
    hgrepos = []
    issue_num = 24687
    keywords = ['patch']
    message_count = 6.0
    messages = ['247153', '247164', '247171', '247172', '247173', '247174']
    nosy_count = 4.0
    nosy_names = ['ncoghlan', 'benjamin.peterson', 'python-dev', 'yselivanov']
    pr_nums = []
    priority = 'high'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue24687'
    versions = ['Python 3.5', 'Python 3.6']

    @1st1
    Copy link
    Member Author

    1st1 commented Jul 22, 2015

    A simple way of reproducing the issue is to try to compile the following piece of code with refleaks check mode on:

       def foo(a:(yield)): pass

    Since '(yield)' expression is outside of a function, it will trigger a SyntaxError.

    There is a subtle bug in compile.c though, specifically in compiler_visit_argannotation method; it should return -1 in case of error, but the VISIT macro it uses returns 0 on errors.

    Attached patch uses 'compiler_visit_expr' directly returning correct error code.

    @1st1 1st1 added the interpreter-core (Objects, Python, Grammar, and Parser dirs) label Jul 22, 2015
    @benjaminp
    Copy link
    Contributor

    I would prefer that compiler_visit_argannotation[s] be fixed to use the normal calling convention.

    @1st1
    Copy link
    Member Author

    1st1 commented Jul 23, 2015

    I would prefer that compiler_visit_argannotation[s] be fixed to use the normal calling convention.

    Agree, new patch attached.

    @benjaminp
    Copy link
    Contributor

    Seems fine to me.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Jul 23, 2015

    New changeset b5a7f529b4ac by Yury Selivanov in branch '3.5':
    Issue bpo-24687: Plug refleak on SyntaxError in function parameters annotations.
    https://hg.python.org/cpython/rev/b5a7f529b4ac

    New changeset cf91ae981afd by Yury Selivanov in branch 'default':
    Merge 3.5 (Issue bpo-24687)
    https://hg.python.org/cpython/rev/cf91ae981afd

    @1st1
    Copy link
    Member Author

    1st1 commented Jul 23, 2015

    Thanks, Benjamin!

    @1st1 1st1 closed this as completed Jul 23, 2015
    @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)
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants