Fix #121021: Avoid size change of addon_modules during iteration
Copy modules before filtering `addon_modules` to avoid change of dictionnary size during iterations. Otherwise errors can be triggerd when running `python -m pytest test.py` since it may modify the module dict. Co-authored-by: Alexis-19 <alexis-19@noreply.localhost> Pull Request: https://projects.blender.org/blender/blender/pulls/121100
This commit is contained in:
@@ -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()
|
||||
if type(mod_dict := getattr(item[1], "__dict__", None)) is dict
|
||||
if mod_dict.get("__addon_enabled__")
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user