Added an explanatory comment. Refs #22017

This commit is contained in:
Alex Gaynor 2014-04-02 09:47:18 -07:00
parent 666990a2a0
commit 608e6eb295
1 changed files with 3 additions and 0 deletions

View File

@ -81,6 +81,9 @@ def gen_filenames():
Yields a generator over filenames referenced in sys.modules and translation
files.
"""
# N.B. ``list(...)`` is needed, because this runs in parallel with
# application code which might be mutating ``sys.modules``, and this will
# fail with RuntimeError: cannot mutate dictionary while iterating
filenames = [filename.__file__ for filename in list(sys.modules.values())
if hasattr(filename, '__file__')]