This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author dfortunov
Recipients dfortunov, docs@python
Date 2020-06-06.23:23:07
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1591485787.87.0.566129309531.issue40895@roundup.psfhosted.org>
In-reply-to
Content
The doccumentation at https://docs.python.org/3.10/library/weakref.html cautions that the WeakKeyDictionary and WeakValueDictionary are susceptible to the problem of dictionary mutation during iteration.

These notes present the user with a problem that has no easy solution.

I dug into the implementation and found that fortunately, Antoine Pitrou already addressed this challenge (10 years ago!) by introducing an _IterationGuard context manager to the implementation, which delays mutation while an iteration is in progress.

I asked for confirmation and Antoine agreed that these notes could be removed:
https://github.com/python/cpython/commit/c1baa601e2b558deb690edfdf334fceee3b03327#commitcomment-39514438
History
Date User Action Args
2020-06-06 23:23:07dfortunovsetrecipients: + dfortunov, docs@python
2020-06-06 23:23:07dfortunovsetmessageid: <1591485787.87.0.566129309531.issue40895@roundup.psfhosted.org>
2020-06-06 23:23:07dfortunovlinkissue40895 messages
2020-06-06 23:23:07dfortunovcreate