mirror of
https://github.com/python/cpython.git
synced 2025-12-31 12:33:28 +00:00
gh-119070: Fix py.exe handling of /usr/bin/env commands missing extension (GH-119426)
This commit is contained in:
parent
a62681c405
commit
bc01c5d225
3 changed files with 14 additions and 1 deletions
|
|
@ -717,3 +717,11 @@ def test_literal_shebang_invalid_template(self):
|
|||
f"{expect} arg1 {script}",
|
||||
data["stdout"].strip(),
|
||||
)
|
||||
|
||||
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``.
|
||||
|
|
@ -846,7 +846,7 @@ searchPath(SearchInfo *search, const wchar_t *shebang, int shebangLength)
|
|||
}
|
||||
|
||||
wchar_t filename[MAXLEN];
|
||||
if (wcsncpy_s(filename, MAXLEN, command, lastDot)) {
|
||||
if (wcsncpy_s(filename, MAXLEN, command, commandLength)) {
|
||||
return RC_BAD_VIRTUAL_PATH;
|
||||
}
|
||||
|
||||
|
|
@ -858,6 +858,8 @@ searchPath(SearchInfo *search, const wchar_t *shebang, int shebangLength)
|
|||
}
|
||||
}
|
||||
|
||||
debug(L"# Search PATH for %s\n", filename);
|
||||
|
||||
wchar_t pathVariable[MAXLEN];
|
||||
int n = GetEnvironmentVariableW(L"PATH", pathVariable, MAXLEN);
|
||||
if (!n) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue