From 458367e60c14fd1b443af4ed7a3fd5135b6d0c35 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Wed, 22 Jul 2026 08:53:27 +0300 Subject: [PATCH] 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 --- Lib/test/test_venv.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) 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) -- 2.47.3