Fixed cascaded imports which could prevent to apply threading patches. Therefore eric7

Mon, 07 Feb 2022 22:02:35 +0100

author
T.Rzepka <Tobias.Rzepka@gmail.com>
date
Mon, 07 Feb 2022 22:02:35 +0100
branch
eric7
changeset 8940
e91951ff3bbd
parent 8939
c88bb019e2b5
child 8941
e1f6a9e53979
child 8943
23f9c7b9e18e

Fixed cascaded imports which could prevent to apply threading patches. Therefore
breakpoints were ignored in such circumstances.

eric7/DebugClients/Python/ModuleLoader.py file | annotate | diff | comparison | revisions
--- 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