mirror of
https://github.com/python/cpython.git
synced 2025-10-02 05:12:23 +00:00
Issue #21905: Avoid RuntimeError in pickle.whichmodule() when sys.modules is mutated while iterating.
Patch by Olivier Grisel.
This commit is contained in:
commit
5f6a7556bf
3 changed files with 7 additions and 1 deletions
|
@ -280,7 +280,9 @@ def whichmodule(obj, name, allow_qualname=False):
|
||||||
module_name = getattr(obj, '__module__', None)
|
module_name = getattr(obj, '__module__', None)
|
||||||
if module_name is not None:
|
if module_name is not None:
|
||||||
return module_name
|
return module_name
|
||||||
for module_name, module in sys.modules.items():
|
# 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()):
|
||||||
if module_name == '__main__' or module is None:
|
if module_name == '__main__' or module is None:
|
||||||
continue
|
continue
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -498,6 +498,7 @@ Eddy De Greef
|
||||||
Grant Griffin
|
Grant Griffin
|
||||||
Andrea Griffini
|
Andrea Griffini
|
||||||
Duncan Grisby
|
Duncan Grisby
|
||||||
|
Olivier Grisel
|
||||||
Fabian Groffen
|
Fabian Groffen
|
||||||
Eric Groo
|
Eric Groo
|
||||||
Dag Gruneau
|
Dag Gruneau
|
||||||
|
|
|
@ -162,6 +162,9 @@ Core and Builtins
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- Issue #21905: Avoid RuntimeError in pickle.whichmodule() when sys.modules
|
||||||
|
is mutated while iterating. Patch by Olivier Grisel.
|
||||||
|
|
||||||
- Issue #11271: concurrent.futures.Executor.map() now takes a *chunksize*
|
- Issue #11271: concurrent.futures.Executor.map() now takes a *chunksize*
|
||||||
argument to allow batching of tasks in child processes and improve
|
argument to allow batching of tasks in child processes and improve
|
||||||
performance of ProcessPoolExecutor. Patch by Dan O'Reilly.
|
performance of ProcessPoolExecutor. Patch by Dan O'Reilly.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue