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

PEG Parser: Invalid targets for augassign and except succeed #84798

Closed
lysnikolaou opened this issue May 14, 2020 · 2 comments
Closed

PEG Parser: Invalid targets for augassign and except succeed #84798

lysnikolaou opened this issue May 14, 2020 · 2 comments
Assignees
Labels
3.9 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error

Comments

@lysnikolaou
Copy link
Contributor

BPO 40618
Nosy @gvanrossum, @lysnikolaou, @pablogsal
PRs
  • bpo-40618: Disallow invalid targets in augassign and except clauses #20083
  • 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/lysnikolaou'
    closed_at = <Date 2020-05-14.22:54:13.450>
    created_at = <Date 2020-05-14.00:15:04.010>
    labels = ['interpreter-core', 'type-bug', '3.9']
    title = 'PEG Parser: Invalid targets for augassign and except succeed'
    updated_at = <Date 2020-05-14.22:54:13.449>
    user = 'https://github.com/lysnikolaou'

    bugs.python.org fields:

    activity = <Date 2020-05-14.22:54:13.449>
    actor = 'lys.nikolaou'
    assignee = 'lys.nikolaou'
    closed = True
    closed_date = <Date 2020-05-14.22:54:13.450>
    closer = 'lys.nikolaou'
    components = ['Interpreter Core']
    creation = <Date 2020-05-14.00:15:04.010>
    creator = 'lys.nikolaou'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 40618
    keywords = ['patch']
    message_count = 2.0
    messages = ['368809', '368866']
    nosy_count = 3.0
    nosy_names = ['gvanrossum', 'lys.nikolaou', 'pablogsal']
    pr_nums = ['20083']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue40618'
    versions = ['Python 3.9']

    @lysnikolaou
    Copy link
    Contributor Author

    Tuples and lists, which are invalid augmented assignment targets, currently get successfully parsed, without failing.

    ➜  cpython git:(targets-fix) ✗ ./python -X oldparser              
    Python 3.9.0a6+ (heads/master-dirty:75cd8e48c6, May 14 2020, 03:01:42) 
    [GCC 9.3.0] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> (a, b) += (1, 2)
      File "<stdin>", line 1
    SyntaxError: illegal expression for augmented assignment
    
    
    ➜  cpython git:(pr/20076) ./python             
    Python 3.9.0a6+ (heads/pr/20076:bcf5be2772, May 14 2020, 02:15:37) 
    [GCC 9.3.0] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> (a, b) += 1
    SystemError: invalid node type (26) for augmented assignment

    We also accept arbitrary targets in except clauses, while we should only be accepting NAME nodes:

    ➜  cpython git:(master) ./python 
    Python 3.9.0a6+ (heads/master:75cd8e48c6, May 14 2020, 03:14:03) 
    [GCC 9.3.0] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> try:
    ...     pass
    ... except Exception as a.b:
    ...     pass
    ... 
    [1]    135956 segmentation fault (core dumped)  ./python

    @lysnikolaou lysnikolaou added the 3.9 only security fixes label May 14, 2020
    @lysnikolaou lysnikolaou self-assigned this May 14, 2020
    @lysnikolaou lysnikolaou added interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error 3.9 only security fixes labels May 14, 2020
    @lysnikolaou lysnikolaou self-assigned this May 14, 2020
    @lysnikolaou lysnikolaou added interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error labels May 14, 2020
    @pablogsal
    Copy link
    Member

    New changeset ce21cfc by Lysandros Nikolaou in branch 'master':
    bpo-40618: Disallow invalid targets in augassign and except clauses (GH-20083)
    ce21cfc

    @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.9 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants