Removed use of deprecated 'imp' module in the debug client. multi_processing

Sat, 08 Feb 2020 17:01:47 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 08 Feb 2020 17:01:47 +0100
branch
multi_processing
changeset 7403
7446a7eacfc3
parent 7402
bc62b4e1aed4
child 7404
663f1c3d6f53

Removed use of deprecated 'imp' module in the debug client.

eric6/DebugClients/Python/DebugClientBase.py file | annotate | diff | comparison | revisions
--- a/eric6/DebugClients/Python/DebugClientBase.py	Sat Feb 08 16:52:48 2020 +0100
+++ b/eric6/DebugClients/Python/DebugClientBase.py	Sat Feb 08 17:01:47 2020 +0100
@@ -15,11 +15,14 @@
 import traceback
 import os
 import json
-import imp
 import re
 import atexit
 import signal
 import time
+if sys.version_info >= (3, 4):
+    import types
+else:
+    import imp
 
 
 import DebugClientCapabilities
@@ -209,7 +212,10 @@
         self.framenr = 0
         
         # The context to run the debugged program in.
-        self.debugMod = imp.new_module('__main__')
+        if sys.version_info >= (3, 4):
+            self.debugMod = types.ModuleType("__main__")
+        else:
+            self.debugMod = imp.new_module('__main__')
         self.debugMod.__dict__['__builtins__'] = __builtins__
 
         # The list of complete lines to execute.
@@ -907,8 +913,14 @@
                             discoveryStart, top_level_dir=top_level_dir)
                 else:
                     if params["filename"]:
-                        utModule = imp.load_source(
-                            params["testname"], params["filename"])
+                        if sys.version_info >= (3, 4):
+                            import importlib
+                            spec = importlib.util.spec_from_file_location(
+                                params["testname"], params["filename"])
+                            utModule = importlib.util.module_from_spec(spec)
+                        else:
+                            utModule = imp.load_source(
+                                params["testname"], params["filename"])
                     else:
                         utModule = None
                     if params["failed"]:

eric ide

mercurial