Skip to content

Commit 2f9aa38

Browse files
Updated error string
1 parent 114f250 commit 2f9aa38

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

Lib/test/test_patma.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3449,7 +3449,7 @@ def test_class_pattern_not_type(self):
34493449
def test_class_or_union_not_specialform(self):
34503450
from typing import Literal
34513451
name = type(Literal).__name__
3452-
msg = rf"called match pattern must be a class or types.UnionType \(got {name}\)"
3452+
msg = rf"called match pattern must be a class or typing.Union of classes \(got {name}\)"
34533453
w = None
34543454
with self.assertRaisesRegex(TypeError, msg):
34553455
match 1:
@@ -3461,7 +3461,7 @@ def test_legacy_union_type(self):
34613461
from typing import Union
34623462
IntOrStr = Union[int, str]
34633463
name = type(IntOrStr).__name__
3464-
msg = rf"called match pattern must be a class or types.UnionType \(got {name}\)"
3464+
msg = rf"called match pattern must be a class or typing.Union of classes \(got {name}\)"
34653465
w = None
34663466
with self.assertRaisesRegex(TypeError, msg):
34673467
match 1:

Python/ceval.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,7 @@ _PyEval_MatchClass(PyThreadState *tstate, PyObject *subject, PyObject *type,
745745
return NULL;
746746
}
747747
if (!PyType_Check(type)) {
748-
const char *e = "called match pattern must be a class or types.UnionType (got %s)";
748+
const char *e = "called match pattern must be a class or typing.Union of classes (got %s)";
749749
_PyErr_Format(tstate, PyExc_TypeError, e, Py_TYPE(type)->tp_name);
750750
return NULL;
751751
}

0 commit comments

Comments
 (0)