Repository navigation
fix: write case source-check reports atomically - #665
Conversation
Signed-off-by: hizlidepoo <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 33f1cf7dd7
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| fd, temp_name = tempfile.mkstemp(prefix=f".{report.name}.", suffix=".tmp", dir=report.parent) | ||
| temp_path = Path(temp_name) | ||
| try: | ||
| with os.fdopen(fd, "w", encoding="utf-8") as stream: |
There was a problem hiding this comment.
Close the descriptor when fdopen rejects it
When os.fdopen raises—as the new write-failure test explicitly forces—ownership of fd has not transferred, so the raw descriptor remains open. On Windows, that open handle prevents the finally block from unlinking the temporary file, causing a PermissionError that masks the expected "write failed" exception and fails the Windows AMD64 and ARM64 unittest steps in .github/workflows/rust.yml. Close fd on the fdopen failure path before attempting cleanup.
Useful? React with 👍 / 👎.
Fixes #640.
Summary
Verification
PYTHONPATH=. python3 tools/test_check_case_sources.py: PASS — 7 testspython3 -m py_compile tools/check_case_sources.py tools/test_check_case_sources.py: PASSgit diff --check: PASSExact upstream base:
451cc7a47a1220d44ebe292f2c64ec84e55dc3e3.Exact head:
33f1cf7dd78ecbca1e4a0bc88c8c3d724fcdbb11.