summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaymond Hettinger <rhettinger@users.noreply.github.com>2020-04-21 23:20:52 (GMT)
committerGitHub <noreply@github.com>2020-04-21 23:20:52 (GMT)
commit75bedbe2ed4119ff18a2ea86c544b3cf08a92e75 (patch)
treea03d1a82185ca6ba08f717c6ea813da727807db4
parentd3a8d616faf3364b22fde18dce8c168de9368146 (diff)
downloadcpython-75bedbe2ed4119ff18a2ea86c544b3cf08a92e75.zip
cpython-75bedbe2ed4119ff18a2ea86c544b3cf08a92e75.tar.gz
cpython-75bedbe2ed4119ff18a2ea86c544b3cf08a92e75.tar.bz2
bpo-40327: Improve atomicity, speed, and memory efficiency of the items() loop (GH-19628)
-rw-r--r--Lib/pickle.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/Lib/pickle.py b/Lib/pickle.py
index d7adc16..1fc8b0d 100644
--- a/Lib/pickle.py
+++ b/Lib/pickle.py
@@ -339,7 +339,7 @@ def whichmodule(obj, name):
return module_name
# Protect the iteration by using a list copy of sys.modules against dynamic
# modules that trigger imports of other modules upon calls to getattr.
- for module_name, module in list(sys.modules.items()):
+ for module_name, module in sys.modules.copy().items():
if module_name == '__main__' or module is None:
continue
try: