[issue13487] inspect.getmodule fails when module imports change sys.modules
Patrik Simons
report at bugs.python.org
Mon Aug 7 03:57:52 EDT 2017
Patrik Simons added the comment:
list(sys.modules.items()) still raises RuntimeError: dictionary changed size during iteration when another thread imports a module.
I would assume dict.copy() is thread-safe so a working fix could use sys.modules.copy().items()
I hit this bug when printing the name of the caller function using
inspect.stack(). The workaround in this case is calling inspect.stack(context=0).
----------
nosy: +psimons
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue13487>
_______________________________________
More information about the Python-bugs-list
mailing list