Skip to content

Preview mode crash with --fast and walrus in except clause #3420

@JelleZijlstra

Description

@JelleZijlstra
$ black --fast -c '''
try: pass
except (a := 1) as (b := why_does_this_exist): pass
'''
try:
    pass
except (a := 1) as (b := why_does_this_exist):
    pass
$ black --preview --fast -c '''
try: pass
except (a := 1) as (b := why_does_this_exist): pass
'''

try: pass
except (a := 1) as (b := why_does_this_exist): pass
error: cannot format <string>: Cannot parse: 3:9: except a := 1 as (b := why_does_this_exist):
$ black --version
black, 22.12.0 (compiled: yes)
Python (CPython) 3.9.14

Similar to #3419, found this in CI for #3418. This needs --fast because CPython actually rejects walrus here (good call), but the grammar allows it.

This one probably comes from #2939, cc @jpy-git again.

Metadata

Metadata

Assignees

No one assigned

    Labels

    T: bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions