tooling: make the docs link check platform-independent #1525
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1532"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from R0Y00/Xbox2Windows. Originally posted by RenzoWit35 on 2026-11-24T13:43:35Z.
Change
tests/docs_links_check.pyresolved link targets withPath/os.path.normpath, whose behavior depends on the OS:[x](docs\Guide.md)was accepted. On Linuxnormpathkeeps the backslash as part of a filename, so the target is not a tracked file and the check fails. GitHub also treats it as a broken link. The same tree could pass on a Windows machine and fail on Linux CI.[x](docs/Guide.md/)(trailing slash on a file) was accepted on both platforms becausenormpathdrops the trailing slash. GitHub does not resolve it as the file.link_errornow rejects a target containing a backslash (after the script's own unescape and URL-decode) withbackslash in path (use /), and rejects a trailing slash on a tracked file withtrailing slash on a file. A trailing slash on a tracked directory is still accepted. Onlytests/docs_links_check.pychanges (+15 lines).Verification
Before (unmodified
main, Windows, Python 3.14.5), scratch repo with trackeddocs/Guide.md:[x](docs\Guide.md)-> accepted (no error)[x](docs/Guide.md/)-> accepted (no error)posixpath.normpath:docs\Guide.mdstays a single filename containing a backslash (not a tracked path, so rejected);docs/Guide.md/becomesdocs/Guide.md(accepted). I did not run the check on Linux itself.Negative control: the new self-test block run against the unmodified
link_errorfrommainfails with anAssertionError.After:
New self-test cases: backslash link (rejected), trailing slash on a file (rejected),
[dir](docs/)(accepted, control). No real link in the tree trips the new rules.Evidence and follow-up
origin/main1ca0dec1. Run on Windows 11 only; the Linux behavior for the backslash case is reasoned fromposixpath, not run on Linux here.[x](file.md#)(empty fragment) is reported as "heading does not exist" while GitHub treats it as no fragment. Separate behavior, left for a follow-up.AGENTS.mdand thepython-linuxjob, so no registration change.AI-assisted.