Commits

Jeremy Kloth committed bbe4237 Draft Merge

merge defalt

Comments (0)

Files changed (4)

Doc/library/shutil.rst

 
 .. function:: which(cmd, mode=os.F_OK | os.X_OK, path=None)
 
-   Return the full path to an executable which would be run if the given
-   *cmd* was called. If no *cmd* would be called, return ``None``.
+   Return the path to an executable which would be run if the given *cmd*
+   was called. If no *cmd* would be called, return ``None``.
 
    *mode* is a permission mask passed a to :func:`os.access`, by default
    determining if the file exists and executable.
 
     seen = set()
     for dir in path:
-        dir = os.path.normcase(os.path.abspath(dir))
+        dir = os.path.normcase(dir)
         if not dir in seen:
             seen.add(dir)
             for thefile in files:

Lib/test/test_reprlib.py

 import importlib
 import unittest
 
-from test.support import run_unittest, create_empty_file
+from test.support import run_unittest, create_empty_file, verbose
 from reprlib import repr as r # Don't shadow builtin repr
 from reprlib import Repr
 from reprlib import recursive_repr
             # (see http://msdn.microsoft.com/en-us/library/windows/desktop/aa365247%28v=vs.85%29.aspx#maxpath)
             self.skipTest("test paths too long (%d characters) for Windows' 260 character limit"
                           % cached_path_len)
+        elif os.name == 'nt' and verbose:
+            print("len(cached_path_len) =", len(cached_path_len))
 
     def test_module(self):
         self._check_path_limitations(self.pkgname)

Lib/test/test_shutil.py

         rv = shutil.which(self.file, path=self.dir, mode=os.W_OK)
         self.assertIsNone(rv)
 
+    def test_relative(self):
+        old_cwd = os.getcwd()
+        base_dir, tail_dir = os.path.split(self.dir)
+        os.chdir(base_dir)
+        try:
+            rv = shutil.which(self.file, path=tail_dir)
+            self.assertEqual(rv, os.path.join(tail_dir, self.file))
+        finally:
+            os.chdir(old_cwd)
+
     def test_nonexistent_file(self):
         # Return None when no matching executable file is found on the path.
         rv = shutil.which("foo.exe", path=self.dir)