mirror of
https://github.com/python/cpython.git
synced 2026-02-01 04:02:20 +00:00
Issue #28214: Improved exception reporting for problematic __set_name__
attributes.
This commit is contained in:
commit
c4b4d4e2d8
3 changed files with 28 additions and 8 deletions
|
|
@ -7022,8 +7022,13 @@ set_names(PyTypeObject *type)
|
|||
if (set_name != NULL) {
|
||||
tmp = PyObject_CallFunctionObjArgs(set_name, type, key, NULL);
|
||||
Py_DECREF(set_name);
|
||||
if (tmp == NULL)
|
||||
if (tmp == NULL) {
|
||||
_PyErr_FormatFromCause(PyExc_RuntimeError,
|
||||
"Error calling __set_name__ on '%.100s' instance %R "
|
||||
"in '%.100s'",
|
||||
value->ob_type->tp_name, key, type->tp_name);
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
Py_DECREF(tmp);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue