Closed
Description
Bug report
Bug description:
Currently dictionary watchers deliver the PyDict_EVENT_ADDED
event before they have done everything that is necessary to ensure success. If the dictionary requires a resize for insertion to succeed (or a new keys object needs to be allocated from an empty dict) and that fails then the dictionary watcher will have inconsistent state to what's stored in the dictionary. Watchers should only receive the event when the dictionary implementation is guaranteed that it will succeed.
The event can still be delivered before the insertion happens meaning there's no visible change in behavior except for the OOM case.
CPython versions tested on:
3.12, CPython main branch
Operating systems tested on:
Linux