mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 22:35:52 +01:00
[PR #720] [MERGED] classify_carve: close mkstemp fd on fdopen error and restore mode before unlink (CLASSIFY-CARVE-STAGE-CLEANUP) #759
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#759
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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 Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/720
Author: @kirigayakazima
Created: 11/24/2026
Status: ✅ Merged
Merged: 11/24/2026
Merged by: @aslan2142
Base:
main← Head:fix/classify-carve-stage-cleanup📝 Commits (1)
8d296d8classify_carve: close mkstemp fd on fdopen error and restore mode before unlink📊 Changes
2 files changed (+79 additions, -1 deletions)
View changed files
📝
tests/test_classify_carve.py(+72 -0)📝
tools/classify_carve.py(+7 -1)📄 Description
Claimed in the coordination issue as: CLASSIFY-CARVE-STAGE-CLEANUP https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7132017328
What and why
Hardens
tools/classify_carve.pywhen publishingtypes.jsonfails:mkstempfdonos.fdopenfailure: Wrapsos.fdopen(fd, ...)so if wrapping the descriptor raises,os.close(fd)runs before re-raising (matchingtools/world_grid_atlas.py). On Windows, leavingfdopen also causesos.unlink(temp)inexcept BaseException:to fail withPermissionError: [WinError 32]and leak.types-*.tmp.os.unlink(temp): On Windows,os.chmod(temp, published_mode(dest))copies0o444ontotempbeforeos.replace(temp, dest); whenos.replacefails over a read-onlytypes.json,os.unlink(temp)hitsPermissionErrorand leaves.types-*.tmpbehind. Callingos.chmod(temp, 0o600)beforeos.unlink(temp)lets the cleanup removetemp.Adds 3 synthetic regression tests in
tests/test_classify_carve.py.Tested
Windows 11 x64, Python 3.14.7, CPU only, synthetic index JSON only (no game files). Commit
8d296d81584d028ce317cb2f332bb8f6f63089cc.python -I tests/test_classify_carve.py -v:main(21625bca) with the three new tests: all 3 fail (leaked.types-*.tmpand unclosedfdinfdopenerror path);python -I tests/test_ci_registration.py: 15 tests, OK.python -I tests/test_text_write_line_endings.py: 3 tests, OK.python -I scripts/check_no_game_data.py tools/classify_carve.py tests/test_classify_carve.py,python -m compileall -q tools tests,git diff --check: clean (exit0).GPUs tested: n/a
AI-assisted: yes
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a: no translator change)🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.