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 — Use standard terminology in class pattern error message · Issue #144702 · python/cpython

Use standard terminology in class pattern error message #144702

New issue
Copy link
New issue
Copy link
Closed
Closed
Use standard terminology in class pattern error message#144702
Copy link
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-featureA feature request or enhancementA feature request or enhancement

Description

@sharkdp
sharkdp
opened on Feb 11, 2026
Issue body actions

Feature or enhancement

Proposal:

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

I am therefore suggesting to change the message to "class pattern must refer to a class".

See #103576 for a PR that previously changed this error message (from "… must be a type" to "… must be a class").

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

No response

Linked PRs

  • gh-144702: Use standard terminology in class pattern error message #144703
Reacted by Alex Waygood

Activity

  1. sharkdp
    added
    type-featureA feature request or enhancementA feature request or enhancement
    on Feb 11, 2026
  2. picnixz
    added
    interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)
    on Feb 11, 2026
  3. AlexWaygood
    added a commit that references this issue on Feb 19, 2026

    gh-144702: Use standard terminology in class pattern error message (#…

    1d09916
  4. AlexWaygood
    closed this as completedon Feb 19, 2026
  5. brijkapadia
    added a commit that references this issue on Feb 28, 2026

    pythongh-144702: Use standard terminology in class pattern error mess…

    749f404
  6. ljfp
    added a commit that references this issue on Apr 25, 2026

    pythongh-144702: Use standard terminology in class pattern error mess…

    9d92a1a
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

    interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-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 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.