eric7/DebugClients/Python/coverage/backward.py

branch
eric7
changeset 8527
2bd1325d727e
parent 8312
800c432b34c8
diff -r 587202572b10 -r 2bd1325d727e eric7/DebugClients/Python/coverage/backward.py
--- a/eric7/DebugClients/Python/coverage/backward.py	Fri Aug 20 19:56:17 2021 +0200
+++ b/eric7/DebugClients/Python/coverage/backward.py	Sat Aug 21 14:21:44 2021 +0200
@@ -78,7 +78,9 @@
 
 try:
     import reprlib
-except ImportError:
+except ImportError:             # pragma: not covered
+    # We need this on Python 2, but in testing environments, a backport is
+    # installed, so this import isn't used.
     import repr as reprlib
 
 # A function to iterate listlessly over a dict's items, and one to get the
@@ -215,9 +217,6 @@
             items = ("{}={!r}".format(k, self.__dict__[k]) for k in keys)
             return "{}({})".format(type(self).__name__, ", ".join(items))
 
-        def __eq__(self, other):
-            return self.__dict__ == other.__dict__
-
 
 def format_local_datetime(dt):
     """Return a string with local timezone representing the date.
@@ -245,15 +244,17 @@
 
     """
     try:
-        from importlib.machinery import SourceFileLoader
+        import importlib.util as importlib_util
     except ImportError:
-        SourceFileLoader = None
+        importlib_util = None
 
     if modfile is None:
         modfile = modname + '.py'
-    if SourceFileLoader:
-        # pylint: disable=no-value-for-parameter, deprecated-method
-        mod = SourceFileLoader(modname, modfile).load_module()
+    if importlib_util:
+        spec = importlib_util.spec_from_file_location(modname, modfile)
+        mod = importlib_util.module_from_spec(spec)
+        sys.modules[modname] = mod
+        spec.loader.exec_module(mod)
     else:
         for suff in imp.get_suffixes():                 # pragma: part covered
             if suff[0] == '.py':

eric ide

mercurial