Skip to content

Commit 1177f20

Browse files
committed
gh-130425: Add "Did you mean" suggestion for del obj.attr
1 parent 38642bf commit 1177f20

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Add ``"Did you mean"`` suggestion when using ``del obj.attr`` if ``attr``
2+
does not exist.

Objects/dictobject.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6898,6 +6898,7 @@ store_instance_attr_lock_held(PyObject *obj, PyDictValues *values,
68986898
PyErr_Format(PyExc_AttributeError,
68996899
"'%.100s' object has no attribute '%U'",
69006900
Py_TYPE(obj)->tp_name, name);
6901+
_PyObject_SetAttributeErrorContext(obj, name);
69016902
return -1;
69026903
}
69036904

0 commit comments

Comments
 (0)