mirror of
https://github.com/python/cpython.git
synced 2026-01-06 15:32:22 +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
|
|
@ -288,16 +288,16 @@ PyFloat_AsDouble(PyObject *op)
|
|||
if (!PyFloat_CheckExact(res)) {
|
||||
if (!PyFloat_Check(res)) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"%.50s.__float__ returned non-float (type %.50s)",
|
||||
Py_TYPE(op)->tp_name, Py_TYPE(res)->tp_name);
|
||||
"%T.__float__() must return a float, not %T",
|
||||
op, res);
|
||||
Py_DECREF(res);
|
||||
return -1;
|
||||
}
|
||||
if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
|
||||
"%.50s.__float__ returned non-float (type %.50s). "
|
||||
"%T.__float__() must return a float, not %T. "
|
||||
"The ability to return an instance of a strict subclass of float "
|
||||
"is deprecated, and may be removed in a future version of Python.",
|
||||
Py_TYPE(op)->tp_name, Py_TYPE(res)->tp_name)) {
|
||||
op, res)) {
|
||||
Py_DECREF(res);
|
||||
return -1;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue