mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
gh-125608: Trigger dictionary watchers when inline values change (#125611)
Dictionary watchers on an object's attributes dictionary (`object.__dict__`) were not triggered when the managed dictionary used the object's inline values.
This commit is contained in:
parent
0cd21406bf
commit
5989eb7446
3 changed files with 35 additions and 6 deletions
|
@ -6835,15 +6835,24 @@ store_instance_attr_lock_held(PyObject *obj, PyDictValues *values,
|
|||
}
|
||||
|
||||
PyObject *old_value = values->values[ix];
|
||||
if (old_value == NULL && value == NULL) {
|
||||
PyErr_Format(PyExc_AttributeError,
|
||||
"'%.100s' object has no attribute '%U'",
|
||||
Py_TYPE(obj)->tp_name, name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (dict) {
|
||||
PyInterpreterState *interp = _PyInterpreterState_GET();
|
||||
PyDict_WatchEvent event = (old_value == NULL ? PyDict_EVENT_ADDED :
|
||||
value == NULL ? PyDict_EVENT_DELETED :
|
||||
PyDict_EVENT_MODIFIED);
|
||||
_PyDict_NotifyEvent(interp, event, dict, name, value);
|
||||
}
|
||||
|
||||
FT_ATOMIC_STORE_PTR_RELEASE(values->values[ix], Py_XNewRef(value));
|
||||
|
||||
if (old_value == NULL) {
|
||||
if (value == NULL) {
|
||||
PyErr_Format(PyExc_AttributeError,
|
||||
"'%.100s' object has no attribute '%U'",
|
||||
Py_TYPE(obj)->tp_name, name);
|
||||
return -1;
|
||||
}
|
||||
_PyDictValues_AddToInsertionOrder(values, ix);
|
||||
if (dict) {
|
||||
assert(dict->ma_values == values);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue