]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-154419: Find the fish shell in test_venv (GH-154420)
authorSerhiy Storchaka <storchaka@gmail.com>
Wed, 22 Jul 2026 05:53:27 +0000 (08:53 +0300)
committerGitHub <noreply@github.com>
Wed, 22 Jul 2026 05:53:27 +0000 (05:53 +0000)
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 <noreply@anthropic.com>
Lib/test/test_venv.py

index 58ae85fb268042eec28344a5dbd7c5afb897ed71..e98e52c2ea2045324749c7a7d0bdcfd6092bb7e7 100644 (file)
@@ -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)