diff -r cb297930d2cf Lib/shutil.py --- a/Lib/shutil.py Thu Jan 17 23:36:08 2013 +0100 +++ b/Lib/shutil.py Thu Jan 17 23:24:15 2013 +0000 @@ -1078,7 +1078,7 @@ # Short circuit. If we're given a full path which matches the mode # and it exists, we're done here. - if _access_check(cmd, mode): + if os.path.isabs(cmd) and _access_check(cmd, mode): return cmd path = (path or os.environ.get("PATH", os.defpath)).split(os.pathsep) diff -r cb297930d2cf Lib/test/test_shutil.py --- a/Lib/test/test_shutil.py Thu Jan 17 23:36:08 2013 +0100 +++ b/Lib/test/test_shutil.py Thu Jan 17 23:24:15 2013 +0000 @@ -1316,6 +1316,21 @@ self.assertEqual(rv, os.path.join(tail_dir, self.file)) finally: os.chdir(old_cwd) + + def test_cwd(self): + old_cwd = os.getcwd() + base_dir, _ = os.path.split(self.dir) + os.chdir(self.dir) + try: + rv = shutil.which(self.file, path=base_dir) + if sys.platform == "win32": + # Windows: current directory implicitly on PATH + self.assertEqual(rv, os.path.join(os.curdir, self.file)) + else: + # Other platforms: shouldn't match in the current directory. + self.assertIsNone(rv) + finally: + os.chdir(old_cwd) def test_nonexistent_file(self): # Return None when no matching executable file is found on the path.