From a13ff29bd87b42fa8e6fad7bdabe9da27e1f6a88 Mon Sep 17 00:00:00 2001 From: jfa Date: Thu, 21 Oct 2021 13:39:36 +0300 Subject: [PATCH] [bos #26531] [CEA] Shaper tests fail with SEGFAULT. Use copy of sys.modules to avoid exception: dictionary changed size during iteration. --- src/PythonAPI/model/dump/DumpAssistant.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/PythonAPI/model/dump/DumpAssistant.py b/src/PythonAPI/model/dump/DumpAssistant.py index b1b40edeb..8c94d1e75 100644 --- a/src/PythonAPI/model/dump/DumpAssistant.py +++ b/src/PythonAPI/model/dump/DumpAssistant.py @@ -50,8 +50,11 @@ class DumpAssistant(ModelHighAPI.ModelHighAPI_Dumper): def collectFeatures(self): self.myFeatures = {} self.myWrapperNames = {} - for aModule in sys.modules: - for aName, anObj in inspect.getmembers(sys.modules[aModule], inspect.isclass): + # Fixing [bos #26531] [CEA] Shaper tests fail with SEGFAULT + # Use copy of sys.modules to avoid exception "dictionary changed size during iteration" + sys_modules = sys.modules.copy() + for aModule in sys_modules: + for aName, anObj in inspect.getmembers(sys_modules[aModule], inspect.isclass): if issubclass(anObj, ModelHighAPI.ModelHighAPI_Interface) and hasattr(anObj, "ID") and anObj.dump != ModelHighAPI.ModelHighAPI_Interface.dump: self.myFeatures[anObj.ID()] = anObj self.myWrapperNames[anObj.ID()] = aName -- 2.39.2