eric7/DebugClients/Python/ModuleLoader.py

branch
eric7
changeset 8940
e91951ff3bbd
parent 8881
54e42bc2437a
--- a/eric7/DebugClients/Python/ModuleLoader.py	Mon Feb 07 11:18:45 2022 +0100
+++ b/eric7/DebugClients/Python/ModuleLoader.py	Mon Feb 07 22:02:35 2022 +0100
@@ -28,7 +28,7 @@
         """
         self.__dbgClient = debugClient
         
-        self.__enableImportHooks = True
+        self.__enableImportHooks = set()
         
         # reset already imported thread module to apply hooks at next import
         for moduleName in ("thread", "_thread", "threading"):
@@ -59,7 +59,7 @@
         """
         module = importlib.import_module(fullname)
         sys.modules[fullname] = module
-        
+        self.__enableImportHooks.remove(fullname)
         ## Add hook for _thread.start_new_thread
         if (
             fullname == '_thread' and
@@ -110,7 +110,6 @@
             self.__dbgClient.patchQThread(module)
             patchQProcess(module, self.__dbgClient)
         
-        self.__enableImportHooks = True
         return module
     
     def find_spec(self, fullname, path, target=None):
@@ -127,15 +126,15 @@
         @return module spec object pointing to the module loader
         @rtype ModuleSpec
         """
-        if fullname in sys.modules or not self.__dbgClient.debugging:
+        if fullname in sys.modules or self.__dbgClient.debugging is False:
             return None
         
         if (
             fullname in self.__modulesToPatch and
-            self.__enableImportHooks
+            fullname not in self.__enableImportHooks
         ):
             # Disable hook to be able to import original module
-            self.__enableImportHooks = False
+            self.__enableImportHooks.add(fullname)
             return importlib.machinery.ModuleSpec(fullname, self)
         
         return None

eric ide

mercurial