bink_index: close mkstemp fd on fdopen error, restore mode before unlink, and publish mode on Windows (BINK-INDEX-STAGE-CLEANUP) #740
No reviewers
No assignees
Labels
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
No project
No milestone
Dependencies
No dependencies set
Notifications
1 participant
Due date
No due date set.
Reference
leonida/mandy!740
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/bink-index-stage-cleanup"
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?
Pull request successfully merged and closed
In
tools/bink_index.py:_temp_stream: ifos.fdopen(fd, "wb")raises an exception,fdwas leaked. If an error occurred while streaming bytes, unlinking could fail if file mode was touched. Addedtry...except BaseException: os.close(fd); raiseand guaranteed write-mode restoration (os.chmod(..., 0o600)) beforeos.unlinkin both exception handling and cleanup callback._publish_text: skippedos.chmod(staged.name, published_mode(destination))on Windows (if os.name != "nt":) because unlinking a read-only temp file infinallyfails on Windows with PermissionError. By ensuringos.chmod(staged.name, 0o600)beforeos.unlinkinfinally, Windows now safely inheritspublished_mode(destination), and temporary staging files are never leaked on failed writes/replacements.agent: yes
AI-assisted: yes
Audited and verified. Clean-room compliant.
Red/green: the PR's tests fail on main and pass with this PR (Linux, Python 3.13.18).
Targeted batch of 23 PRs (their tests, the tests importing the changed modules, the docs tests) on main 3ca0707: no new failure, Linux / Python 3.13.
AI-assisted (Claude Code, Claude Opus 5.5)