Skip to content

bpo-45353: Remind sys.modules users to copy when iterating. #28842

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
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Doc/library/sys.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1073,7 +1073,11 @@ always available.
This is a dictionary that maps module names to modules which have already been
loaded. This can be manipulated to force reloading of modules and other tricks.
However, replacing the dictionary will not necessarily work as expected and
deleting essential items from the dictionary may cause Python to fail.
deleting essential items from the dictionary may cause Python to fail. If
you want to iterate over this global dictionary always use
``sys.modules.copy()`` or ``tuple(sys.modules)`` to avoid exceptions as its
size may change during iteration as a side effect of code or activity in
other threads.


.. data:: orig_argv
Expand Down