[PR #121] [CLOSED] tools/mc_command: check PATHEXT on Windows when shutil.which misses path without extension #173

Closed
opened 2026-11-26 20:17:01 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/121
Author: @Andretuta
Created: 11/24/2026
Status: ❌ Closed

Base: main ← Head: old-pr/9856


📝 Commits (2)

  • ed833a9 tools/mc_command: check PATHEXT on Windows when shutil.which misses path without extension
  • 4342513 tests/mc_command: add cross-platform PATHEXT fallback test and clarify comment

📊 Changes

2 files changed (+19 additions, -2 deletions)

View changed files

📝 tests/test_mc_command.py (+10 -0)
📝 tools/mc_command.py (+9 -2)

📄 Description

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.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/121 **Author:** [@Andretuta](https://github.com/Andretuta) **Created:** 11/24/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `old-pr/9856` --- ### 📝 Commits (2) - [`ed833a9`](https://github.com/ubiquitarianism/leonida/commit/ed833a9935132ba348848fa2a875cad0bf7f218b) tools/mc_command: check PATHEXT on Windows when shutil.which misses path without extension - [`4342513`](https://github.com/ubiquitarianism/leonida/commit/434251342fe834643d5d532cc81b217442220328) tests/mc_command: add cross-platform PATHEXT fallback test and clarify comment ### 📊 Changes **2 files changed** (+19 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `tests/test_mc_command.py` (+10 -0) 📝 `tools/mc_command.py` (+9 -2) </details> ### 📄 Description > 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. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 20:17:01 +01:00
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
starred/leonida#173
No description provided.