From c57f2cc6ffb12de8808e28347c5c35433f582d61 Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Fri, 10 Nov 2023 18:28:56 +0900 Subject: [PATCH] Avoid RuntimeError caused by iteration over sys.modules As is described in the doc[1], we should not iterate over sys.modules directly because sys.modules can be changed during iterations. [1] https://docs.python.org/3/library/sys.html#sys.modules Change-Id: Iad4e19744ee78996728e44f3a1446c1c282ad437 --- os_ken/tests/switch/tester.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/os_ken/tests/switch/tester.py b/os_ken/tests/switch/tester.py index e39513b7..62b88a1c 100644 --- a/os_ken/tests/switch/tester.py +++ b/os_ken/tests/switch/tester.py @@ -56,7 +56,7 @@ CLSNAME_ALIASES = { ('os_ken.lib.packet.ospf', 'StringifyMixin'): '' } -for modname, moddef in sys.modules.items(): +for modname, moddef in sys.modules.copy().items(): if not modname.startswith(PKT_LIB_PATH) or not moddef: continue for (clsname, clsdef, ) in inspect.getmembers(moddef):