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 — gh-144702: Use standard terminology in class pattern error message by sharkdp · Pull Request #144703 · python/cpython

Conversation

@sharkdp

@sharkdp sharkdp commented Feb 11, 2026 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

When trying to use a class pattern to match on a non-class object, we currently get the following error message:

Traceback (most recent call last):
  File "/tmp/test.py", line 2, in <module>
    case len():
         ~~~^^
TypeError: called match pattern must be a class

The terminology "called match pattern" here is a bit confusing. It's not used anywhere else as far as I can tell, and for a beginner, it might read like something is actually being called here.

The documentation consistently refers to these patterns as "class patterns":

  • https://docs.python.org/3/reference/compound_stmts.html#class-patterns
  • https://peps.python.org/pep-0635/#class-patterns
  • https://docs.python.org/3/library/ast.html#ast.MatchClass
  • https://docs.python.org/3/reference/datamodel.html#customizing-positional-arguments-in-class-pattern-matching

Here, we change this message to "class pattern must refer to a class".

  • Issue: Use standard terminology in class pattern error message #144702

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@sharkdp
Use standard terminology in class pattern error message
950c015
When trying to use a class pattern to match on a non-class object, we
currently get the following error message:

    Traceback (most recent call last):
      File "/tmp/test.py", line 2, in <module>
        case len():
             ~~~^^
    TypeError: called match pattern must be a class

The terminology "called match pattern" here is a bit confusing. It's not
used anywhere else as far as I can tell, and for a beginner, it might
read like something is actually being called here.

The documentation consistently refers to these patterns as "class
patterns":

* https://docs.python.org/3/reference/compound_stmts.html#class-patterns
* https://peps.python.org/pep-0635/#class-patterns
* https://docs.python.org/3/library/ast.html#ast.MatchClass
* https://docs.python.org/3/reference/datamodel.html#customizing-positional-arguments-in-class-pattern-matching

Here, we change this message to "class pattern must refer to a class".
@sharkdp
sharkdp requested a review from markshannon as a code owner February 11, 2026 10:31
@bedevere-app bedevere-app Bot added the awaiting review label Feb 11, 2026
@bedevere-app bedevere-app Bot mentioned this pull request Feb 11, 2026
Use standard terminology in class pattern error message #144702
Closed
johnslavik
johnslavik approved these changes Feb 11, 2026
View reviewed changes

@johnslavik johnslavik left a comment •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume we don't need a test. Without the entire check, _PyEval_MatchClass will still appropriately fail with a TypeError.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-app bedevere-app Bot added awaiting core review and removed awaiting review labels Feb 11, 2026
AlexWaygood
AlexWaygood approved these changes Feb 11, 2026
View reviewed changes
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting core review labels Feb 11, 2026
@AlexWaygood
AlexWaygood requested a review from brandtbucher February 11, 2026 16:44
@AlexWaygood
AlexWaygood merged commit 1d09916 into python:main Feb 19, 2026
64 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the awaiting merge label Feb 19, 2026
@AlexWaygood

AlexWaygood commented Feb 19, 2026

Copy link
Copy Markdown
Member

Thanks for the PR! 😃

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

brijkapadia pushed a commit to brijkapadia/cpython that referenced this pull request Feb 28, 2026
@sharkdp @brijkapadia
pythongh-144702: Use standard terminology in class pattern error mess…
749f404
…age (python#144703)
ljfp pushed a commit to ljfp/cpython that referenced this pull request Apr 25, 2026
@sharkdp @ljfp
pythongh-144702: Use standard terminology in class pattern error mess…
9d92a1a
…age (python#144703)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@johnslavik johnslavik johnslavik approved these changes
@AlexWaygood AlexWaygood AlexWaygood approved these changes
@markshannon markshannon Awaiting requested review from markshannon markshannon is a code owner
@brandtbucher brandtbucher Awaiting requested review from brandtbucher

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@sharkdp @AlexWaygood @johnslavik
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — 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.