]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
bpo-13487: Use sys.modules.copy() in inspect.getmodule() for thread safety. (GH-18786)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Thu, 5 Mar 2020 01:03:29 +0000 (17:03 -0800)
committerGitHub <noreply@github.com>
Thu, 5 Mar 2020 01:03:29 +0000 (17:03 -0800)
commita12381233a243ba7d5151ebf060feb57dd540bef
treef61ced2679be73cf9092c8b9d064413139630a95
parent6bb67452d4f21e2d948dafce7644b1d66e5efcb8
bpo-13487: Use sys.modules.copy() in inspect.getmodule() for thread safety. (GH-18786)

`list(sys.modules.items())` was apparently not immune to "dictionary
changed size during iteration" errors.

Tested internally using an integration test that has run into this a couple of times in the past two years.  With this patch applied, the test is no longer flaky.
(cherry picked from commit 85cf1d514b84dc9a4bcb40e20a12e1d82ff19f20)

Co-authored-by: Gregory P. Smith <gps@google.com>
Lib/inspect.py
Misc/NEWS.d/next/Library/2020-03-04-16-10-59.bpo-13487.gqe4Fb.rst [new file with mode: 0644]