eric6/DebugClients/Python/coverage/files.py

branch
multi_processing
changeset 7428
27c55a3d0b89
parent 7427
362cd1b6f81a
--- a/eric6/DebugClients/Python/coverage/files.py	Mon Feb 17 19:23:27 2020 +0100
+++ b/eric6/DebugClients/Python/coverage/files.py	Sat Feb 22 17:03:43 2020 +0100
@@ -1,5 +1,5 @@
 # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
-# For details: https://bitbucket.org/ned/coveragepy/src/default/NOTICE.txt
+# For details: https://github.com/nedbat/coveragepy/blob/master/NOTICE.txt
 
 """File wrangling."""
 
@@ -59,6 +59,7 @@
 
     """
     if filename not in CANONICAL_FILENAME_CACHE:
+        cf = filename
         if not os.path.isabs(filename):
             for path in [os.curdir] + sys.path:
                 if path is None:
@@ -69,9 +70,9 @@
                 except UnicodeError:
                     exists = False
                 if exists:
-                    filename = f
+                    cf = f
                     break
-        cf = abs_file(filename)
+        cf = abs_file(cf)
         CANONICAL_FILENAME_CACHE[filename] = cf
     return CANONICAL_FILENAME_CACHE[filename]
 
@@ -122,7 +123,9 @@
             else:
                 try:
                     files = os.listdir(head)
-                except OSError:
+                except Exception:
+                    # This will raise OSError, or this bizarre TypeError:
+                    # https://bugs.python.org/issue1776160
                     files = []
                 _ACTUAL_PATH_LIST_CACHE[head] = files
             normtail = os.path.normcase(tail)
@@ -156,9 +159,8 @@
 
 
 @contract(returns='unicode')
-def abs_file(filename):
-    """Return the absolute normalized form of `filename`."""
-    path = os.path.expandvars(os.path.expanduser(filename))
+def abs_file(path):
+    """Return the absolute normalized form of `path`."""
     try:
         path = os.path.realpath(path)
     except UnicodeError:
@@ -169,6 +171,13 @@
     return path
 
 
+def python_reported_file(filename):
+    """Return the string as Python would describe this file name."""
+    if env.PYBEHAVIOR.report_absolute_files:
+        filename = os.path.abspath(filename)
+    return filename
+
+
 RELATIVE_DIR = None
 CANONICAL_FILENAME_CACHE = None
 set_relative_directory()
@@ -335,7 +344,7 @@
     def pprint(self):       # pragma: debugging
         """Dump the important parts of the PathAliases, for debugging."""
         for regex, result in self.aliases:
-            print("{0!r} --> {1!r}".format(regex.pattern, result))
+            print("{!r} --> {!r}".format(regex.pattern, result))
 
     def add(self, pattern, result):
         """Add the `pattern`/`result` pair to the list of aliases.

eric ide

mercurial