GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Improve SyntaxError message for `match` · Issue #151128 · python/cpython

Improve SyntaxError message for match #151128

New issue
Copy link
New issue
Copy link
Closed
Closed
Improve SyntaxError message for match#151128
Copy link
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancementA feature request or enhancement

Description

@IvyXu420
IvyXu420
opened on Jun 9, 2026
Issue body actions

Feature or enhancement

Proposal:

Currently, Python raises:

SyntaxError: invalid syntax. Did you mean 'with'?

for switch foo:.

This is confusing and irrelevant, because in many other programming languages, switch is a reserved keyword that serves almost the same function as Python’s match.

Thus, users typing switch almost certainly intended to use match, mistakenly substituting the keyword from other languages, rather than meaning to write a with statement.

Therefore, I believe it’s better to raise:

SyntaxError: invalid syntax. Did you mean 'match'?

in this case.

Additionally, code with typos like mach foo: or matc foo: currently lacks a keyword typo suggestion.

Has this already been discussed elsewhere?

I have already discussed this feature proposal on Discourse

Links to previous discussion of this feature:

https://discuss.python.org/t/improve-syntaxerror-message-for-match/107684

Linked PRs

  • gh-151128: Improve SyntaxError message for cross language keywords #151129
Reacted by Dan Redding, Eduardo Villalpando Mello and James Addison

Activity

  1. IvyXu420
    added
    type-featureA feature request or enhancementA feature request or enhancement
    on Jun 9, 2026
  2. zang-langyan commented on Jun 9, 2026

    @zang-langyan
    zang-langyan
    on Jun 9, 2026
    Contributor
    More actions

    #151129 take a look out this pr, it should do the trick

  3. serhiy-storchaka commented on Jun 9, 2026

    @serhiy-storchaka
    serhiy-storchaka
    on Jun 9, 2026
    Member
    More actions

    See also #146406 as a precedence.

  4. StanFromIreland
    added
    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
    on Jun 9, 2026
  5. serhiy-storchaka
    added a commit that references this issue on Jun 15, 2026

    gh-151128: Improve SyntaxError message for cross language keywords (G…

    5ea1e90
  6. serhiy-storchaka
    closed this as completedon Jun 15, 2026
  7. philthompson10
    added a commit that references this issue on Jun 17, 2026

    pythongh-151128: Improve SyntaxError message for cross language keywo…

    82394ff
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

    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancementA feature request or enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402520 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.