fix(xiaoyuzhou): verify python candidates actually run before selecting one (#566) - #717
Open
smartworldarafath wants to merge 1 commit into
Conversation
…ng one (Panniantong#566) `ensure_python()` accepted the first interpreter whose *name* existed on PATH. On Windows Git Bash `command -v python3` resolves to the Microsoft Store App Execution Alias (`%LOCALAPPDATA%\Microsoft\WindowsApps\python3.exe`), which exits 49 without running Python. That stub shadows a real `python` install later in PATH, so the script selected it and every Python step afterwards failed. The first Python step is the URL check, so the user-visible symptom is a misleading rejection of perfectly valid links: $ bash transcribe.sh https://www.xiaoyuzhoufm.com/episode/123 ❌ 仅支持 xiaoyuzhoufm.com 及其子域的 http/https 链接 Existence-only detection cannot tell "exists" from "can execute" — the same failure mode `agent_reach/probe.py` documents for stale venv shims, and the pattern `test.sh` already uses (`command -v … && python3 -c …`). Fix: each candidate must execute `-c ""` before it is accepted; otherwise the script falls through to the next candidate and only reports "no usable Python" when none of them runs. Regression test `test_transcribe_script_skips_unrunnable_python3_stub` injects a `python3` that exists but returns 49 (like the Store alias) plus a working `python`, then asserts the URL reaches curl instead of being rejected. It fails before this change and passes after it. Verified: 576 passed / 4 failed locally; the 4 remaining failures are Windows symlink-privilege environment failures that also fail on unmodified main, and the 6 previously failing `test_xiaoyuzhou_install.py` cases now pass.
smartworldarafath
force-pushed
the
fix/xiaoyuzhou-python-interpreter-probe
branch
from
September 22, 2026 17:27
a7e0e36 to
a4ad685
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
ensure_python()inagent_reach/scripts/transcribe_xiaoyuzhou.shonly checked whether aninterpreter name exists on PATH — never whether it can actually run:
On Windows (Git Bash)
command -v python3resolves to the Microsoft Store App Execution Alias%LOCALAPPDATA%\Microsoft\WindowsApps\python3.exe. That file ships on PATH by default, but it isnot Python — it just exits:
Since that alias is ordered before a real
pythoninstall (e.g....\Programs\Python\Python312\python.exe), the script selected the stub and every subsequentPython call failed. The first step that uses Python is the URL check, so the user-visible error
points in the wrong direction entirely — a perfectly valid link is reported as an unsupported host:
Result: the script is unusable on Windows even when a working Python is installed, and the
python3/python/py -3probe added in #575 cannot detect it either, because that checkis existence-only too.
Fix
A candidate is accepted only after it actually executes; otherwise the script falls through to the
next candidate and reports "no usable Python" only when none of them runs:
Only
ensure_python()changes (5 logic lines). Linux/macOS behaviour is unchanged: a realpython3returns 0 from-c ""immediately, so it is still selected first.Regression test
New
tests/test_xiaoyuzhou_install.py::test_transcribe_script_skips_unrunnable_python3_stubreproduces the field condition using the
BASH_ENVinjection the file's tests already use:python3→ exists but returns 49 (same as the Store alias)python→ points at the running test interpreter (sys.executable)It asserts the valid URL reaches
curl(and is then stopped by the fake curl's exit code 42)instead of being misreported as an unsupported host.
Verification
pytest tests/test_xiaoyuzhou_install.py→ 16 passed (10 passed / 6 failed before the fix)pytest(full suite, Windows 10 + Git Bash + Python 3.12) → 576 passed / 4 failed / 28 skipped.All 4 remaining failures are
WinError 1314symlink-privilege environment failures that fail onunmodified
mainhere as well; they are unrelated to this change and already handled by test(windows): skip symlink tests when symlinks are unavailable #681("skip symlink tests when symlinks are unavailable").
ruff check tests agent_reach→ All checks passedRefs #566 (the remaining piece of P1-2, "transcribe.sh 在 Windows 完全不可用")