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.

classification
Title: weakref documentation contains cautions about dictionary mutation problems that have been solved in the implementation
Type: behavior Stage: resolved
Components: Documentation Versions: Python 3.10, Python 3.9, Python 3.8, Python 3.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: dfortunov, docs@python, miss-islington, pitrou
Priority: normal Keywords: patch

Created on 2020-06-06 23:23 by dfortunov, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 20687 merged dfortunov, 2020-06-06 23:41
PR 20791 merged miss-islington, 2020-06-10 20:27
PR 20792 merged pitrou, 2020-06-10 20:30
PR 20793 merged pitrou, 2020-06-10 20:31
Messages (5)
msg370860 - (view) Author: Daniel Fortunov (dfortunov) * Date: 2020-06-06 23:23
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
msg371241 - (view) Author: miss-islington (miss-islington) Date: 2020-06-10 20:26
New changeset 1642c0ef750f96664a98cadb09301d492098d2fb by Daniel Fortunov in branch 'master':
bpo-40895: Update weakref documentation to remove old warnings (GH-20687)
https://github.com/python/cpython/commit/1642c0ef750f96664a98cadb09301d492098d2fb
msg371242 - (view) Author: miss-islington (miss-islington) Date: 2020-06-10 20:34
New changeset 18e07ba931c68eb5ab5262d4e57fe58c302686de by Miss Islington (bot) in branch '3.9':
bpo-40895: Update weakref documentation to remove old warnings (GH-20687)
https://github.com/python/cpython/commit/18e07ba931c68eb5ab5262d4e57fe58c302686de
msg371245 - (view) Author: miss-islington (miss-islington) Date: 2020-06-10 20:37
New changeset 049039832da3d02592d680cebf71ab8a665a6564 by Antoine Pitrou in branch '3.7':
[3.7] bpo-40895: Update weakref documentation to remove old warnings (GH-20687) (GH-20793)
https://github.com/python/cpython/commit/049039832da3d02592d680cebf71ab8a665a6564
msg371246 - (view) Author: miss-islington (miss-islington) Date: 2020-06-10 20:38
New changeset 972aba86ede0bf254e16a760639a1ff8df298578 by Antoine Pitrou in branch '3.8':
[3.8] bpo-40895: Update weakref documentation to remove old warnings (GH-20687) (GH-20792)
https://github.com/python/cpython/commit/972aba86ede0bf254e16a760639a1ff8df298578
History
Date User Action Args
2022-04-11 14:59:32adminsetgithub: 85072
2020-06-10 20:39:29pitrousetstatus: open -> closed
type: behavior
stage: patch review -> resolved
resolution: fixed
versions: + Python 3.7, Python 3.8, Python 3.9
2020-06-10 20:38:46miss-islingtonsetmessages: + msg371246
2020-06-10 20:37:25miss-islingtonsetmessages: + msg371245
2020-06-10 20:34:05miss-islingtonsetmessages: + msg371242
2020-06-10 20:31:25pitrousetpull_requests: + pull_request19989
2020-06-10 20:30:20pitrousetnosy: + pitrou
pull_requests: + pull_request19988
2020-06-10 20:27:19miss-islingtonsetpull_requests: + pull_request19987
2020-06-10 20:26:57miss-islingtonsetnosy: + miss-islington
messages: + msg371241
2020-06-06 23:41:05dfortunovsetkeywords: + patch
stage: patch review
pull_requests: + pull_request19901
2020-06-06 23:23:07dfortunovcreate