tools/mc_command: check PATHEXT on Windows when shutil.which misses path without extension #121

Closed
github-bot wants to merge 2 commits from gh-pr/121/head into gh-pr/121/base
Owner

@⁠Andretuta on GitHub · 2026-11-24 02:23 UTC · original
ubiquitarianism:old-pr/9856 → main · +19 −2 · 2 files · 2 commits · closed without merging

Carried over from old PR 9856 by lordon1a in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch old-pr/9856, exactly that PR's last commit. All carried-over PRs are listed in #17.
Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it.
lordon1a: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one.


Original description (mentions and #N references are disabled; the numbers refer to the old repository):

Claim: https://github.com/ProjectLeonida/Leonida/issues/9677#issuecomment-7116717748

What and why

On Windows with Python 3.11, shutil.which(raw) returns None for a path that contains a directory separator and omits its .exe extension (e.g., C:\Program Files\LLVM\bin\llvm-mc), causing mc_command.split_command() to split on spaces and failing tests/test_mc_command.py (test_real_path_with_spaces_and_no_extension).

Falls back to checking os.path.isfile(raw + ext) across PATHEXT on os.name == "nt" when shutil.which(raw) returns None.

Verification (Windows 11 Home 26H2, CPython 3.11.9, CPU only, no game files)

  • Before fix (2d53a8055): python -I tests/test_mc_command.py -> FAIL (1 failure: test_real_path_with_spaces_and_no_extension).
  • After fix: python -I tests/test_mc_command.py -v -> 20/20 tests OK in 1.832s.
  • python -I scripts/check_no_game_data.py tools/mc_command.py: clean (rc=0).
  • git diff --check: clean (rc=0).

AI-assisted.

**@⁠Andretuta** on GitHub · 2026-11-24 02:23 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/121) `ubiquitarianism:old-pr/9856` → `main` · +19 −2 · 2 files · 2 commits · closed without merging > Carried over from **old PR 9856** by `lordon1a` in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch `old-pr/9856`, exactly that PR's last commit. All carried-over PRs are listed in #17. > Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it. > `lordon1a`: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one. --- Original description (mentions and `#N` references are disabled; the numbers refer to the old repository): Claim: https://github.com/ProjectLeonida/Leonida/issues/9677#issuecomment-7116717748 ### What and why On Windows with Python 3.11, `shutil.which(raw)` returns `None` for a path that contains a directory separator and omits its `.exe` extension (e.g., `C:\Program Files\LLVM\bin\llvm-mc`), causing `mc_command.split_command()` to split on spaces and failing `tests/test_mc_command.py` (`test_real_path_with_spaces_and_no_extension`). Falls back to checking `os.path.isfile(raw + ext)` across `PATHEXT` on `os.name == "nt"` when `shutil.which(raw)` returns `None`. ### Verification (Windows 11 Home 26H2, CPython 3.11.9, CPU only, no game files) - Before fix (`2d53a8055`): `python -I tests/test_mc_command.py` -> **FAIL (1 failure: `test_real_path_with_spaces_and_no_extension`)**. - After fix: `python -I tests/test_mc_command.py -v` -> **20/20 tests OK in 1.832s**. - `python -I scripts/check_no_game_data.py tools/mc_command.py`: clean (`rc=0`). - `git diff --check`: clean (`rc=0`). AI-assisted.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 08:45:08 +00:00
github-bot closed this pull request 2026-11-26 08:45:09 +00:00
Author
Owner

@⁠Dezmonius on GitHub · 2026-11-24 07:03 UTC · original

Independent Windows recheck of this draft (4342513) against current main (d42773d). I ran the SplitCommandTest class and a separate end-to-end probe that passes an unquoted path containing spaces, with the .exe suffix omitted, to split_command and launches the resulting argv. The probe used a temporary copy of Windows' whoami.exe as the fixture.

CPython Main parser tests / launch Draft parser tests / launch
3.11.9 16/17; path splits, launch not attempted 17/17; exit 0
3.12.10 17/17; exit 0 17/17; exit 0
3.13.15 17/17; exit 0 17/17; exit 0
3.14.7 17/17; exit 0 17/17; exit 0

This confirms the original 3.11 bug and fix. The README on main requires Python 3.12+, and the Python documentation records the Windows PATHEXT behavior change in 3.12. I would leave this as a legacy compatibility patch unless the project decides to support Python 3.11 again.

CPU-only, no game files. AI-assisted (Codex).

**@⁠Dezmonius** on GitHub · 2026-11-24 07:03 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/121#issuecomment-7124568239) Independent Windows recheck of this draft (`4342513`) against current `main` (`d42773d`). I ran the `SplitCommandTest` class and a separate end-to-end probe that passes an unquoted path containing spaces, with the `.exe` suffix omitted, to `split_command` and launches the resulting argv. The probe used a temporary copy of Windows' `whoami.exe` as the fixture. | CPython | Main parser tests / launch | Draft parser tests / launch | | --- | --- | --- | | 3.11.9 | 16/17; path splits, launch not attempted | 17/17; exit 0 | | 3.12.10 | 17/17; exit 0 | 17/17; exit 0 | | 3.13.15 | 17/17; exit 0 | 17/17; exit 0 | | 3.14.7 | 17/17; exit 0 | 17/17; exit 0 | This confirms the original 3.11 bug and fix. [The README on main](https://github.com/ubiquitarianism/leonida/blob/d42773d0734d5fd7b3a32a1bfd536f61186322a5/README.md) requires Python 3.12+, and [the Python documentation](https://docs.python.org/3/library/shutil.html#shutil.which) records the Windows PATHEXT behavior change in 3.12. I would leave this as a legacy compatibility patch unless the project decides to support Python 3.11 again. CPU-only, no game files. AI-assisted (Codex).
Author
Owner

@⁠aslan2142 on GitHub · 2026-11-24 19:18 UTC · original

This carry-over of old upstream PR 9856 has been taken over in #979, so I'm closing this draft as #17 describes. The branch old-pr/9856 stays.

AI-assisted (Claude Code, Claude Opus 5.5).

**@⁠aslan2142** on GitHub · 2026-11-24 19:18 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/121#issuecomment-7141894727) This carry-over of old upstream PR 9856 has been taken over in #979, so I'm closing this draft as #17 describes. The branch `old-pr/9856` stays. AI-assisted (Claude Code, Claude Opus 5.5).

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.