From: Serhiy Storchaka Date: Wed, 22 Jul 2026 05:53:27 +0000 (+0300) Subject: gh-154419: Find the fish shell in test_venv (GH-154420) X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=458367e60c14fd1b443af4ed7a3fd5135b6d0c35;p=thirdparty%2FPython%2Fcpython.git gh-154419: Find the fish shell in test_venv (GH-154420) shutil.which('fish') can find the unrelated "Go Fish" game, which is shipped on several BSD systems. Search PATH for an executable which behaves like the fish shell instead. Co-authored-by: Claude Opus 4.8 --- diff --git a/Lib/test/test_venv.py b/Lib/test/test_venv.py index 58ae85fb2680..e98e52c2ea20 100644 --- a/Lib/test/test_venv.py +++ b/Lib/test/test_venv.py @@ -783,8 +783,16 @@ class BasicTest(BaseTest): shadows one of those builtins (a common pattern for `.`-style directory navigators) must not hijack the prompt or break status restoration. """ - fish = shutil.which('fish') - if fish is None: + # Some systems have an unrelated "fish" game (see fish(6)), which + # can precede the fish shell in PATH. + for dirname in None, *os.get_exec_path(): + fish = shutil.which('fish', path=dirname) + if fish is not None and subprocess.run( + [fish, '-c', 'echo $FISH_VERSION'], + stdin=subprocess.DEVNULL, + capture_output=True).stdout.strip(): + break + else: self.skipTest('fish required for this test') rmtree(self.env_dir) builder = venv.EnvBuilder(clear=True)