]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-40327: Improve atomicity, speed, and memory efficiency of the items() loop (GH...
authorRaymond Hettinger <rhettinger@users.noreply.github.com>
Tue, 21 Apr 2020 23:20:52 +0000 (16:20 -0700)
committerGitHub <noreply@github.com>
Tue, 21 Apr 2020 23:20:52 +0000 (16:20 -0700)
Lib/pickle.py

index d7adc162c98de959446a9263da462a286f505c27..1fc8b0d26c6c47b369f88e5e8633defd17ed9b1f 100644 (file)
@@ -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: