Fix #121021: Avoid size change of addon_modules during iteration #121100

Merged
YimingWu merged 4 commits from fix-121021 into main 2024-05-11 08:58:32 +02:00
1 changed files with 2 additions and 1 deletions

View File

@ -584,8 +584,9 @@ def disable_all():
#
# Either way, running 3rd party logic here can cause undefined behavior.
# Use direct `__dict__` access to bypass `__getattr__`, see: #111649.
modules = sys.modules.copy()
addon_modules = [
item for item in sys.modules.items()
item for item in modules.items()
ChengduLittleA marked this conversation as resolved Outdated

This should still call .items(), otherwise it'll be iterating over the dictionary keys instead.

This should still call `.items()`, otherwise it'll be iterating over the dictionary keys instead.
if type(mod_dict := getattr(item[1], "__dict__", None)) is dict
if mod_dict.get("__addon_enabled__")
]