Skip to content

Python crashes with new parser on invalid exception handlers #84801

Closed

Description

@hauntsaninja
BPO 40621
Nosy @pablogsal, @hauntsaninja
PRs
  • bpo-40621: except clauses should use NAME, not target #20086
  • Superseder
  • bpo-40618: PEG Parser: Invalid targets for augassign and except succeed
  • 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 2020-05-14.20:13:22.952>
    created_at = <Date 2020-05-14.07:40:23.735>
    labels = []
    title = 'Python crashes with new parser on invalid exception handlers'
    updated_at = <Date 2020-05-14.20:13:22.952>
    user = 'https://github.com/hauntsaninja'

    bugs.python.org fields:

    activity = <Date 2020-05-14.20:13:22.952>
    actor = 'pablogsal'
    assignee = 'none'
    closed = True
    closed_date = <Date 2020-05-14.20:13:22.952>
    closer = 'pablogsal'
    components = []
    creation = <Date 2020-05-14.07:40:23.735>
    creator = 'hauntsaninja'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 40621
    keywords = ['patch']
    message_count = 2.0
    messages = ['368818', '368825']
    nosy_count = 2.0
    nosy_names = ['pablogsal', 'hauntsaninja']
    pr_nums = ['20086']
    priority = 'normal'
    resolution = 'duplicate'
    stage = 'resolved'
    status = 'closed'
    superseder = '40618'
    type = None
    url = 'https://bugs.python.org/issue40621'
    versions = []

    Activity

    1. hauntsaninja commented on May 14, 2020

      @hauntsaninja
      ContributorAuthor
      ~/dev/cpython master λ ./python.exe --version --version                                           
      Python 3.9.0a6+ (heads/master:a15c9b3a05, May 14 2020, 00:31:47) 
      [Clang 11.0.0 (clang-1100.0.33.17)]
      
      
      
      # should raise a syntax error, instead crashes
      ~/dev/cpython master λ cat test.py 
      try:
          1 / 0
      except Exception as a.b:
          pass
      ~/dev/cpython master λ ./python.exe test.py            
      [1]    63986 bus error  ./python.exe test.py
      ~/dev/cpython master λ ./python.exe -Xoldparser test.py
        File "/Users/shantanu/dev/cpython/test.py", line 3
          except Exception as a.b:
                               ^
      SyntaxError: invalid syntax
      
      
      
      # should raise a syntax error, instead passes
      ~/dev/cpython master λ cat test2.py
      try:
          1 / 0
      except Exception as (a):
          pass
      ~/dev/cpython master λ ./python.exe test2.py
      ~/dev/cpython master λ ./python.exe -Xoldparser test2.py
        File "/Users/shantanu/dev/cpython/test2.py", line 3
          except Exception as (a):
                              ^
      SyntaxError: invalid syntax
      
      
      
      # should raise a syntax error, instead crashes
      ~/dev/cpython master λ cat test3.py
      try:
          1 / 0
      except Exception as a[0]:
          pass
      ~/dev/cpython master λ ./python.exe test3.py
      [1]    64206 bus error  ./python.exe test3.py
      ~/dev/cpython master λ ./python.exe -Xoldparser test3.py
        File "/Users/shantanu/dev/cpython/test3.py", line 3
          except Exception as a[0]:
                               ^
      SyntaxError: invalid syntax
      

      The old grammar expects a NAME here, but the new grammar attempts to use a target (https://docs.python.org/3/reference/grammar.html). Seems like we should just go back to using NAME.

    2. pablogsal commented on May 14, 2020

      @pablogsal
      Member

      Thanks for the issue and the PR @hauntsaninja. Unfortunately, I think this is already covered by bpo-20083 and https://bugs.python.org/issue40618

    3. 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

    No one assigned

      Labels

      No labels
      No labels

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions