Uh oh!
There was an error while loading. Please reload this page.
gh-100530: Change the error message for MatchClass - #103576
Merged
Merged
Conversation
brandtbucher
approved these changes
Apr 17, 2023
brandtbucher
left a comment
Member
There was a problem hiding this comment.
Thanks, just one suggestion on the NEWS entry:
Uh oh!
There was an error while loading. Please reload this page.
…e-100530.OR6-sn.rst Co-authored-by: Brandt Bucher <brandtbucher@gmail.com>
brandtbucher
commented
Apr 18, 2023
Member
Thanks! |
bedevere-bot
commented
Apr 18, 2023
|
carljm added a commit
to carljm/cpython
that referenced
this pull request
Apr 20, 2023
* main: (24 commits) pythongh-98040: Move the Single-Phase Init Tests Out of test_imp (pythongh-102561) pythongh-83861: Fix datetime.astimezone() method (pythonGH-101545) pythongh-102856: Clean some of the PEP 701 tokenizer implementation (python#103634) pythongh-102856: Skip test_mismatched_parens in WASI builds (python#103633) pythongh-102856: Initial implementation of PEP 701 (python#102855) pythongh-103583: Add ref. dependency between multibytecodec modules (python#103589) pythongh-83004: Harden msvcrt further (python#103420) pythonGH-88342: clarify that `asyncio.as_completed` accepts generators yielding tasks (python#103626) pythongh-102778: IDLE - make sys.last_exc available in Shell after traceback (python#103314) pythongh-103582: Remove last references to `argparse.REMAINDER` from docs (python#103586) pythongh-103583: Always pass multibyte codec structs as const (python#103588) pythongh-103617: Fix compiler warning in _iomodule.c (python#103618) pythongh-103596: [Enum] do not shadow mixed-in methods/attributes (pythonGH-103600) pythonGH-100530: Change the error message for non-class class patterns (pythonGH-103576) pythongh-95299: Remove lingering setuptools reference in installer scripts (pythonGH-103613) [Doc] Fix a typo in optparse.rst (python#103504) pythongh-101100: Fix broken reference `__format__` in `string.rst` (python#103531) pythongh-95299: Stop installing setuptools as a part of ensurepip and venv (python#101039) pythonGH-103484: Docs: add linkcheck allowed redirects entries for most cases (python#103569) pythongh-67230: update whatsnew note for csv changes (python#103598) ...
sharkdp added a commit
to sharkdp/cpython
that referenced
this pull request
Feb 11, 2026
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 python#103576 for a PR that previously changed this message (from "… must be a type" to "… must be a class").
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
@brandtbucher do you agree with this wording? :)