bpo-40895: Update weakref documentation to remove old warnings#20687
Conversation
…ainst the destruction of weakref'ed objects while iterating.
0443f9e to
d566ae9
Compare
|
Slight copy-paste failure on my part resulting in me using the wrong BPO issue number throughout. The title and body of this PR have been corrected and I've force-pushed a corrected commit message. Please excuse the wrong BPO issue in the underlying branch name -- it's not possible to fix that without closing the PR and opening a new one. |
That's fine, I've certainly made that mistake myself. While the name makes it easier to identify the purpose of branch when reviewing multiple ongoing PRs at the same time, it's definitely not a significant issue. The more important part is the PR title for discoverability and proper linking to the bpo issue, but that's been fixed. So, I wouldn't worry about it. :-) |
There was a problem hiding this comment.
Thanks for the PR @asqui and for bringing this to our attention. It's often easy to forget to update old parts of the documentation, so we greatly appreciate the reminder; even more so when a PR is opened to address it.
LGTM. From looking over the other parts of the documentation, I don't see any other warnings or notes about not changing the size of the WeakDictionarys during iteration that should be removed. I'll leave it to @pitrou to give a final review though since he made the underlying code changes.
|
We might be able to backport this to earlier versions considering the age of the commit, but we typically backport documentation changes only down to the current default version for docs.python.org (3.8 at the moment), as that gives the most significant benefit to the highest number of users. Antoine, do you think this case might be an exception or should we just backport to 3.9 and 3.8? The removal of this warning seems quite significant and can expand the user perception for usage of the weakref dictionaries, so it might be relevant to users looking at older versions of the documentation. I'm thinking we could pretty reasonably backport it to 3.7 as well, but we should probably double check w/ Ned first since that branch is just a couple versions away from being security-only. |
|
Given that we're fixing an oversight in a previous commit, I think it's fine to backport to 3.7. |
|
Thanks @asqui for the PR 🌮🎉.. I'm working now to backport this PR to: 3.7, 3.8, 3.9. |
|
GH-20791 is a backport of this pull request to the 3.9 branch. |
|
Sorry, @asqui, I could not cleanly backport this to |
|
Sorry @asqui, I had trouble checking out the |
…ythonGH-20687) 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 @pitrou agreed that these notes could be removed: python@c1baa601e2b558deb690edfdf334fceee3b03327GH-commitcomment-39514438. (cherry picked from commit 1642c0e) Co-authored-by: Daniel Fortunov <[email protected]>
|
GH-20792 is a backport of this pull request to the 3.8 branch. |
…ythonGH-20687) 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 @pitrou agreed that these notes could be removed: python@c1baa601e2b558deb690edfdf334fceee3b03327GH-commitcomment-39514438. (cherry picked from commit 1642c0e) Co-authored-by: Daniel Fortunov <[email protected]>
|
GH-20793 is a backport of this pull request to the 3.7 branch. |
) 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 @pitrou agreed that these notes could be removed: c1baa601e2b558deb690edfdf334fceee3b03327GH-commitcomment-39514438 (cherry picked from commit 1642c0e) Co-authored-by: Daniel Fortunov <[email protected]>
…H-20687) (GH-20793) 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 @pitrou agreed that these notes could be removed: c1baa601e2b558deb690edfdf334fceee3b03327GH-commitcomment-39514438. (cherry picked from commit 1642c0e) Co-authored-by: Daniel Fortunov <[email protected]> Automerge-Triggered-By: @pitrou
…H-20687) (GH-20792) 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 @pitrou agreed that these notes could be removed: c1baa601e2b558deb690edfdf334fceee3b03327GH-commitcomment-39514438. (cherry picked from commit 1642c0e) Co-authored-by: Daniel Fortunov <[email protected]> Automerge-Triggered-By: @pitrou
The doccumentation at https://docs.python.org/3.10/library/weakref.html cautions that the
WeakKeyDictionaryandWeakValueDictionaryare 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
_IterationGuardcontext manager to the implementation, which delays mutation while an iteration is in progress.I asked for confirmation and @pitrou agreed that these notes could be removed:
c1baa60#commitcomment-39514438
https://bugs.python.org/issue40895
Automerge-Triggered-By: @pitrou