diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-02-11-11-28-25.gh-issue-144702.XjFumv.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-02-11-11-28-25.gh-issue-144702.XjFumv.rst new file mode 100644 index 00000000000..01d2b6570de --- /dev/null +++ b/Misc/NEWS.d/next/Core_and_Builtins/2026-02-11-11-28-25.gh-issue-144702.XjFumv.rst @@ -0,0 +1,2 @@ +Clarify the error message raised when a class pattern is used to match on a +non-class object. diff --git a/Python/ceval.c b/Python/ceval.c index ab2eef56037..8e905a5e689 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -534,7 +534,7 @@ _PyEval_MatchClass(PyThreadState *tstate, PyObject *subject, PyObject *type, Py_ssize_t nargs, PyObject *kwargs) { if (!PyType_Check(type)) { - const char *e = "called match pattern must be a class"; + const char *e = "class pattern must refer to a class"; _PyErr_Format(tstate, PyExc_TypeError, e); return NULL; }