FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Improve error message for `except a as b.c:` case · Issue #123440 · python/cpython · GitHub

/ cpython Public

Improve error message for except a as b.c: case #123440

Description

Feature or enhancement

Right now the syntax error is not very clear:

I propose to instead use something like:

@JelleZijlstra suggested to use similar error messages to := case, where we also only expect a name:

>>> (a.b := 3)
  File "<unknown>", line 1
    (a.b := 3)
     ^^^
SyntaxError: cannot use assignment expressions with attribute
>>> (a[0] := 3)
  File "<unknown>", line 1
    (a[0] := 3)
     ^^^^
SyntaxError: cannot use assignment expressions with subscript
>>> ((a, b) := 3)
  File "<unknown>", line 1
    ((a, b) := 3)
     ^^^^^^
SyntaxError: cannot use assignment expressions with tuple

I am working on this right now :)

Linked PRs

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


Back | FazBrowse Home | New Git URL