From 1d099164bc0732debb9e93f32ad96a7d3d55a9ba Mon Sep 17 00:00:00 2001 From: David Peter Date: Thu, 19 Feb 2026 14:31:13 +0100 Subject: [PATCH] gh-144702: Use standard terminology in class pattern error message (#144703) --- .../2026-02-11-11-28-25.gh-issue-144702.XjFumv.rst | 2 ++ Python/ceval.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 Misc/NEWS.d/next/Core_and_Builtins/2026-02-11-11-28-25.gh-issue-144702.XjFumv.rst 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; }