[issue45353] sys.modules: dictionary changed size during iteration

2021-10-03 Thread Idan Cohen


New submission from Idan Cohen :

Hi,

When iterating over sys.modules it might be that because of lazy loading or 
that other module reload is being reloaded (even if sys.modules.copy() is being 
used) you will get:

"RuntimeError: dictionary changed size during iteration"

The usage of sys.modules and iteration over it is used in many places

I know that this is a known issue but didn't find any solution or fix for that. 
Also, if there is some work around that might solve this, I would appreciate it.

Thanks,
Idan

--
components: Library (Lib)
messages: 403089
nosy: idan57
priority: normal
severity: normal
status: open
title: sys.modules: dictionary changed size during iteration
versions: Python 3.8

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



[issue45353] sys.modules: dictionary changed size during iteration

2021-10-09 Thread Idan Cohen


Idan Cohen  added the comment:

An example can be found here: 
https://github.com/python/cpython/commit/7058d2d96c5ca4dfc6c754c5cd737c6eb2a8fd67
https://bugs.python.org/issue13487

Those links are about an issue that was until March 2020 with how sys.modules 
is iterated. It is not safe to iterate over since it can get updated during the 
iteration because of lazy importing for example.

If you look in older reports you can find that there us an issue with iterating 
over it and it was not addressed yet at all.

--

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