Commit 950c015
committed
Use standard terminology in class pattern error message
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".1 parent b22ff1e commit 950c015
File tree
2 files changed
+3
-1
lines changed- Misc/NEWS.d/next/Core_and_Builtins
- Python
2 files changed
+3
-1
lines changedLines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
531 | 531 | | |
532 | 532 | | |
533 | 533 | | |
534 | | - | |
| 534 | + | |
535 | 535 | | |
536 | 536 | | |
537 | 537 | | |
| |||
0 commit comments