mirror of https://github.com/python/cpython.git
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:
parent
dcfbd3be9f
commit
c3cfc04a73
|
@ -764,3 +764,11 @@ def test_shebang_command_in_venv(self):
|
||||||
with self.script(f'#! /usr/bin/env {exe.stem} arg1') as script:
|
with self.script(f'#! /usr/bin/env {exe.stem} arg1') as script:
|
||||||
data = self.run_py([script], env=env)
|
data = self.run_py([script], env=env)
|
||||||
self.assertEqual(data["stdout"].strip(), f"{quote(exe)} arg1 {quote(script)}")
|
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)
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
Fixes ``py.exe`` handling of shebangs like ``/usr/bin/env python3.12``,
|
||||||
|
which were previously interpreted as ``python3.exe`` instead of
|
||||||
|
``python3.12.exe``.
|
|
@ -853,7 +853,7 @@ searchPath(SearchInfo *search, const wchar_t *shebang, int shebangLength)
|
||||||
}
|
}
|
||||||
|
|
||||||
wchar_t filename[MAXLEN];
|
wchar_t filename[MAXLEN];
|
||||||
if (wcsncpy_s(filename, MAXLEN, command, lastDot)) {
|
if (wcsncpy_s(filename, MAXLEN, command, commandLength)) {
|
||||||
return RC_BAD_VIRTUAL_PATH;
|
return RC_BAD_VIRTUAL_PATH;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue