Use importlib instead __import__ because it returns the correct module directly.

Sat, 15 Oct 2016 20:36:37 +0200

author
T.Rzepka <Tobias.Rzepka@gmail.com>
date
Sat, 15 Oct 2016 20:36:37 +0200
changeset 5240
71c51aae2f4e
parent 5239
27f56dc07b5b
child 5241
883e7084818d
child 5242
26630d91f4cf

Use importlib instead __import__ because it returns the correct module directly.

DebugClients/Python/ThreadExtension.py file | annotate | diff | comparison | revisions
--- a/DebugClients/Python/ThreadExtension.py	Fri Oct 14 23:02:38 2016 +0200
+++ b/DebugClients/Python/ThreadExtension.py	Sat Oct 15 20:36:37 2016 +0200
@@ -9,6 +9,7 @@
 
 import os.path
 import sys
+import importlib
 
 if sys.version_info[0] == 2:
     import thread as _thread
@@ -269,7 +270,7 @@
         @return reference to the loaded module
         @rtype module
         """
-        module = __import__(fullname)
+        module = importlib.import_module(fullname)
         sys.modules[fullname] = module
         if (fullname == self.threadModName and
                 self._original_start_new_thread is None):
@@ -278,12 +279,12 @@
             module.start_new_thread = self.attachThread
         elif fullname in ['PyQt4.QtCore', 'PyQt5.QtCore',
                           'PySide.QtCore'] and self._qtThread is None:
-            self._qtThread = module.QtCore.QThread
+            self._qtThread = module.QThread
             # _debugClient as a class attribute can't be accessed in following
             # class. Therefore we need a global variable.
             _debugClient = self
             
-            class QThreadWrapper(module.QtCore.QThread):
+            class QThreadWrapper(module.QThread):
                 __qtThreadNumber = 1
                 
                 def __init__(self, *args, **kwargs):

eric ide

mercurial