bpo-43857: Improve the AttributeError message when deleting a missing attribute (#25424)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
This commit is contained in:
Géry Ogam 2022-05-05 15:37:26 +02:00 committed by GitHub
parent 43b135f94e
commit a95138b2c5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 62 additions and 5 deletions

View file

@ -5472,7 +5472,9 @@ _PyObject_StoreInstanceAttribute(PyObject *obj, PyDictValues *values,
values->values[ix] = value;
if (old_value == NULL) {
if (value == NULL) {
PyErr_SetObject(PyExc_AttributeError, name);
PyErr_Format(PyExc_AttributeError,
"'%.100s' object has no attribute '%U'",
Py_TYPE(obj)->tp_name, name);
return -1;
}
_PyDictValues_AddToInsertionOrder(values, ix);