Fixes a rare internal error where new code from version 6.131.1 could
fail if "sys.modules" is simultaneously modified, e.g. as a side
effect of imports executed from another thread. Our Thread-Safety
Policy does not promise that this is supported, but we're happy to
take reasonable fixes.
Thanks to Tony Li for reporting and fixing this issue.
The canonical version of these notes (with links) is on readthedocs.