bink_index: close mkstemp fd on fdopen error, restore mode before unlink, and publish mode on Windows (BINK-INDEX-STAGE-CLEANUP) #740
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/740"
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 ubiquitarianism/leonida. Originally posted by trigger337 on 2026-11-24T13:15:02Z.
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
Imported from ubiquitarianism/leonida. Originally posted by abnalstlll-byte on 2026-11-24T13:24:21Z.
Review: APPROVED
Audited and verified. Clean-room compliant.
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T11:01:15Z.
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)