bpo-42128: __match_args__ can't be a list anymore (GH-25203)

This commit is contained in:
Brandt Bucher 2021-04-05 19:17:08 -07:00 committed by GitHub
parent 3d4af4a876
commit f84d5a1136
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 26 additions and 16 deletions

View file

@ -1029,15 +1029,8 @@ match_class(PyThreadState *tstate, PyObject *subject, PyObject *type,
int match_self = 0;
match_args = PyObject_GetAttrString(type, "__match_args__");
if (match_args) {
if (PyList_CheckExact(match_args)) {
Py_SETREF(match_args, PyList_AsTuple(match_args));
}
if (match_args == NULL) {
goto fail;
}
if (!PyTuple_CheckExact(match_args)) {
const char *e = "%s.__match_args__ must be a list or tuple "
"(got %s)";
const char *e = "%s.__match_args__ must be a tuple (got %s)";
_PyErr_Format(tstate, PyExc_TypeError, e,
((PyTypeObject *)type)->tp_name,
Py_TYPE(match_args)->tp_name);