Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Lib/test/test_launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -764,3 +764,11 @@ def test_shebang_command_in_venv(self):
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)
Original file line number Diff line number Diff line change
@@ -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``.
2 changes: 1 addition & 1 deletion PC/launcher2.c
Original file line number Diff line number Diff line change
Expand Up @@ -853,7 +853,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;
}

Expand Down