[issue13487] inspect.getmodule fails when module imports change sys.modules

2017-08-07 Thread Patrik Simons

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 <rep...@bugs.python.org>
<http://bugs.python.org/issue13487>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13487] inspect.getmodule fails when module imports change sys.modules

2017-09-16 Thread Patrik Simons

Patrik Simons added the comment:

I cannot reproduce. In fact I cannot even get list(d.items())
to raise RuntimeError: dictionary changed size during iteration
for any dict d.

--

___
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue13487>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com