mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
bpo-36433: fix confusing error messages in classmethoddescr_call (GH-12556)
https://bugs.python.org/issue36433
This commit is contained in:
parent
b4d8f28a8a
commit
871309c775
3 changed files with 23 additions and 9 deletions
|
@ -315,20 +315,18 @@ classmethoddescr_call(PyMethodDescrObject *descr, PyObject *args,
|
|||
if (!PyType_Check(self)) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"descriptor '%V' requires a type "
|
||||
"but received a '%.100s'",
|
||||
"but received a '%.100s' instance",
|
||||
descr_name((PyDescrObject *)descr), "?",
|
||||
PyDescr_TYPE(descr)->tp_name,
|
||||
self->ob_type->tp_name);
|
||||
return NULL;
|
||||
}
|
||||
if (!PyType_IsSubtype((PyTypeObject *)self, PyDescr_TYPE(descr))) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"descriptor '%V' "
|
||||
"requires a subtype of '%.100s' "
|
||||
"but received '%.100s",
|
||||
"descriptor '%V' requires a subtype of '%.100s' "
|
||||
"but received '%.100s'",
|
||||
descr_name((PyDescrObject *)descr), "?",
|
||||
PyDescr_TYPE(descr)->tp_name,
|
||||
self->ob_type->tp_name);
|
||||
((PyTypeObject*)self)->tp_name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue