eric6/DebugClients/Python/ThreadExtension.py

changeset 7637
c878e8255972
parent 7635
0cdead130a81
child 7639
422fd05e9c91
diff -r 61566f35ab22 -r c878e8255972 eric6/DebugClients/Python/ThreadExtension.py
--- a/eric6/DebugClients/Python/ThreadExtension.py	Mon Jun 22 17:55:06 2020 +0200
+++ b/eric6/DebugClients/Python/ThreadExtension.py	Tue Jun 23 17:24:18 2020 +0200
@@ -11,11 +11,7 @@
 import sys
 import importlib
 
-if sys.version_info[0] == 2:
-    import thread as _thread
-else:
-    import _thread
-
+import _thread
 import threading
 
 from DebugBase import DebugBase
@@ -54,13 +50,8 @@
         # special objects representing the main scripts thread and frame
         self.mainThread = self
         
-        if sys.version_info[0] == 2:
-            self.threadModName = 'thread'
-        else:
-            self.threadModName = '_thread'
-        
         # reset already imported thread module to apply hooks at next import
-        del sys.modules[self.threadModName]
+        del sys.modules['_thread']
         del sys.modules['threading']
         
         sys.meta_path.insert(0, self)
@@ -260,7 +251,7 @@
         if fullname in sys.modules or not self.debugging:
             return None
         
-        if fullname in [self.threadModName, 'PyQt5.QtCore', 'PySide2.QtCore',
+        if fullname in ['_thread', 'PyQt5.QtCore', 'PySide2.QtCore',
                         'greenlet', 'threading'
                         ] and self.enableImportHooks:
             # Disable hook to be able to import original module
@@ -280,7 +271,7 @@
         """
         module = importlib.import_module(fullname)
         sys.modules[fullname] = module
-        if (fullname == self.threadModName and
+        if (fullname == '_thread' and
                 self._original_start_new_thread is None):
             # make thread hooks available to system
             self._original_start_new_thread = module.start_new_thread
@@ -337,10 +328,7 @@
             module.Thread = ThreadWrapper
             
             # Special handling of threading.(_)Timer
-            if sys.version_info[0] == 2:
-                timer = module._Timer
-            else:
-                timer = module.Timer
+            timer = module.Timer
                 
             class TimerWrapper(timer, ThreadWrapper):
                 """
@@ -353,10 +341,7 @@
                     super(TimerWrapper, self).__init__(
                         interval, function, *args, **kwargs)
             
-            if sys.version_info[0] == 2:
-                module._Timer = TimerWrapper
-            else:
-                module.Timer = TimerWrapper
+            module.Timer = TimerWrapper
         
             # Special handling of threading._DummyThread
             class DummyThreadWrapper(module._DummyThread, ThreadWrapper):

eric ide

mercurial