mirror of
https://github.com/python/cpython.git
synced 2025-11-01 14:11:41 +00:00
gh-130821: Add type information to error messages for invalid return type (GH-130835)
This commit is contained in:
parent
c9d7065188
commit
968f6e523a
14 changed files with 76 additions and 76 deletions
|
|
@ -566,8 +566,8 @@ format_obj(PyObject *v, const char **pbuf, Py_ssize_t *plen)
|
|||
return NULL;
|
||||
if (!PyBytes_Check(result)) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"__bytes__ returned non-bytes (type %.200s)",
|
||||
Py_TYPE(result)->tp_name);
|
||||
"%T.__bytes__() must return a bytes, not %T",
|
||||
v, result);
|
||||
Py_DECREF(result);
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -2793,8 +2793,8 @@ bytes_new_impl(PyTypeObject *type, PyObject *x, const char *encoding,
|
|||
return NULL;
|
||||
if (!PyBytes_Check(bytes)) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"__bytes__ returned non-bytes (type %.200s)",
|
||||
Py_TYPE(bytes)->tp_name);
|
||||
"%T.__bytes__() must return a bytes, not %T",
|
||||
x, bytes);
|
||||
Py_DECREF(bytes);
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue