Skip to content

[3.10] bpo-45353: Remind sys.modules users to copy when iterating. (GH-28842) #28843

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 9, 2021

Conversation

miss-islington
Copy link
Contributor

@miss-islington miss-islington commented Oct 9, 2021

This is true of all dictionaries in Python, but this one tends to
catch people off guard as they don't realize when sys.modules might
change out from underneath them as a hidden side effect of their
code. Copying it first avoids the RuntimeError. An example when
this happens in single threaded code are codecs being loaded which
are an implicit time of use import that most need not think about.
(cherry picked from commit 3d1ca86)

Co-authored-by: Gregory P. Smith greg@krypto.org

https://bugs.python.org/issue45353

Automerge-Triggered-By: GH:gpshead

…-28842)

This is true of all dictionaries in Python, but this one tends to
catch people off guard as they don't realize when sys.modules might
change out from underneath them as a hidden side effect of their
code.  Copying it first avoids the RuntimeError.  An example when
this happens in single threaded code are codecs being loaded which
are an implicit time of use import that most need not think about.
(cherry picked from commit 3d1ca86)

Co-authored-by: Gregory P. Smith <greg@krypto.org>
@miss-islington
Copy link
Contributor Author

@gpshead: Status check is done, and it's a success ✅ .

@miss-islington miss-islington merged commit 459a4db into python:3.10 Oct 9, 2021
@miss-islington miss-islington deleted the backport-3d1ca86-3.10 branch October 9, 2021 19:54
@miss-islington
Copy link
Contributor Author

@gpshead: Status check is done, and it's a success ✅ .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir skip news
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants