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

2021-10-09 Thread Terry J. Reedy
Change by Terry J. Reedy : -- stage: commit review -> resolved ___ Python tracker ___ ___ Python-bugs-list mailing list

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

2021-10-09 Thread miss-islington
miss-islington added the comment: New changeset 459a4db5eae1f5ef063b34c61cc099820aa9ed0a by Miss Islington (bot) in branch '3.10': bpo-45353: Remind sys.modules users to copy when iterating. (GH-28842) https://github.com/python/cpython/commit/459a4db5eae1f5ef063b34c61cc099820aa9ed0a

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

2021-10-09 Thread Gregory P. Smith
Gregory P. Smith added the comment: While arguably unnecessary as it is documented as a dictionary and this is a normal Python dict behavior, it is a global dict and it can be modified at times that are unintuitive to users of all experience levels. A note in the documentation makes sense.

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

2021-10-09 Thread Gregory P. Smith
Gregory P. Smith added the comment: New changeset 3d1ca867ed0e3ae343166806f8ddd9739e568ab4 by Gregory P. Smith in branch 'main': bpo-45353: Remind sys.modules users to copy when iterating. (GH-28842) https://github.com/python/cpython/commit/3d1ca867ed0e3ae343166806f8ddd9739e568ab4

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

2021-10-09 Thread miss-islington
Change by miss-islington : -- nosy: +miss-islington nosy_count: 4.0 -> 5.0 pull_requests: +27155 pull_request: https://github.com/python/cpython/pull/28843 ___ Python tracker

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

2021-10-09 Thread Gregory P. Smith
Change by Gregory P. Smith : -- keywords: +patch pull_requests: +27154 stage: test needed -> patch review pull_request: https://github.com/python/cpython/pull/28842 ___ Python tracker

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

2021-10-09 Thread Terry J. Reedy
Terry J. Reedy added the comment: In #13487, Gregory fixed the problem by using .copy(). That seems to have worked for 1 1/2 years. You still have not reported an actual bug in the current CPython stdlib. Perhaps we should mention in https://docs.python.org/3/library/sys.html#sys.modules

[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

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

2021-10-08 Thread Terry J. Reedy
Terry J. Reedy added the comment: Do you have an example for which "for m in sys.modules: print(m, end=' ')" fails? In particular, is there code in the stdlib that fails iterating over sys.modules? If not the latter, this should be closed as 'Not a bug'. Note that questions about using

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

2021-10-03 Thread Dennis Sweeney
Dennis Sweeney added the comment: One standard way of preventing this is copying the dictionary whenever there's risk of it changing out from under you, as in: modules = sys.modules.copy() for key, value in modules.items(): ... -- nosy: +Dennis Sweeney

[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