test(release): state the O_NOFOLLOW contract per platform - #123
Merged
Conversation
`test_download_verification_reads_through_the_checked_path` asserted that reading a symbolic link directly raises OSError. That is true only where `os.O_NOFOLLOW` exists. Windows has no such flag and no equivalent, which `_no_follow_opener` already documents, so the open succeeds there and the test failed on the windows-latest lane after merge. The assertion that matters holds on every platform and now runs before the platform split: `verify()` refuses a link outright, so no link ever reaches the hash loop. The direct-read assertion now states the real contract for each platform -- refused where `O_NOFOLLOW` exists, followed where it does not, with the explicit `is_symlink` check as the defence there. Verified both branches locally: the POSIX branch on macOS, and the Windows branch by removing `os.O_NOFOLLOW` and reloading the module, where `verify()` still refuses the link. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
Fixes the
windows-latestfailure onmainfrom #122 (1511075).What broke
test_download_verification_reads_through_the_checked_pathended with:That holds only where
os.O_NOFOLLOWexists. Windows has neither the flag noran equivalent, which
_no_follow_openeralready documents by falling back to0, so the open succeeds there:Only the test was wrong. The shipped behaviour is correct on both platforms.
What the test asserts now
The assertion that matters on every platform runs first and is unchanged:
verify()refuses a link outright, so no link ever reaches the hash loop. Thatassertion passed on Windows in the failing run.
The direct-read assertion now states the real per-platform contract - refused
where
O_NOFOLLOWexists, followed where it does not, with the explicitis_symlinkcheck as the whole defence there.Verification
uv run pytest tests/ -qon macOS -> 998 passed, 6 skipped.os.O_NOFOLLOWand reloading themodule.
verify()still refuses the link(
download directory contains a link or non-regular file) and_read_bytesreads through it, which is what the new branch asserts.
uv run ruff check engine/ tests/ scripts/-> clean.🤖 Generated with Claude Code