Skip to content

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

Description

@lysnikolaou
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']

    Activity

    1. lysnikolaou commented on May 14, 2020

      @lysnikolaou
      MemberAuthor

      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
    2. self-assigned this
      on May 14, 2020
    3. added
      interpreter-core(Objects, Python, Grammar, and Parser dirs)
      type-bugAn unexpected behavior, bug, or error
      on May 14, 2020
    4. self-assigned this
      on May 14, 2020
    5. added
      interpreter-core(Objects, Python, Grammar, and Parser dirs)
      type-bugAn unexpected behavior, bug, or error
      on May 14, 2020
    6. pablogsal commented on May 14, 2020

      @pablogsal
      Member

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

    7. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    Labels

    3.9 (EOL)end of lifeinterpreter-core(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions