GH-100530: Change the error message for non-class class patterns (GH-103576)

This commit is contained in:
Nikita Sobolev 2023-04-18 20:41:14 +03:00 committed by GitHub
parent 78cac520c3
commit 07804ce24c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 1 deletions

View File

@ -0,0 +1 @@
Clarify the error message raised when the called part of a class pattern isn't actually a class.

View File

@ -416,7 +416,7 @@ match_class(PyThreadState *tstate, PyObject *subject, PyObject *type,
Py_ssize_t nargs, PyObject *kwargs) Py_ssize_t nargs, PyObject *kwargs)
{ {
if (!PyType_Check(type)) { if (!PyType_Check(type)) {
const char *e = "called match pattern must be a type"; const char *e = "called match pattern must be a class";
_PyErr_Format(tstate, PyExc_TypeError, e); _PyErr_Format(tstate, PyExc_TypeError, e);
return NULL; return NULL;
} }