gh-119070: Fix py.exe handling of /usr/bin/env commands missing extension (GH-119426)

(cherry picked from commit df93f5d4bf)

Co-authored-by: Steve Dower <steve.dower@python.org>
This commit is contained in:
Miss Islington (bot) 2024-05-29 22:06:38 +02:00 committed by GitHub
parent dcfbd3be9f
commit c3cfc04a73
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 12 additions and 1 deletions

View file

@ -764,3 +764,11 @@ class TestLauncher(unittest.TestCase, RunPyMixin):
with self.script(f'#! /usr/bin/env {exe.stem} arg1') as script:
data = self.run_py([script], env=env)
self.assertEqual(data["stdout"].strip(), f"{quote(exe)} arg1 {quote(script)}")
def test_shebang_executable_extension(self):
with self.script('#! /usr/bin/env python3.12') as script:
data = self.run_py([script])
expect = "# Search PATH for python3.12.exe"
actual = [line.strip() for line in data["stderr"].splitlines()
if line.startswith("# Search PATH")]
self.assertEqual([expect], actual)