mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 23:30:53 +01:00
[PR #1789] tools: harden stage_timeline.py parsing, OSError handling and stdout guard #1801
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#1801
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/1789
Author: @kirigayakazima
Created: 11/25/2026
Status: 🔄 Open
Base:
main← Head:fix/stage-timeline-safety📝 Commits (1)
dacbc16tools: harden stage_timeline.py parsing, error handling and stdout guard📊 Changes
2 files changed (+150 additions, -8 deletions)
View changed files
➕
tests/test_stage_timeline.py(+128 -0)📝
tools/stage_timeline.py(+22 -8)📄 Description
Claimed in the coordination issue as: STAGE-TIMELINE-STDOUT-GUARD-AND-PARSER-SAFETY (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7162011238)
What and why
sys.stdout.reconfigure(errors="replace")guard intools/stage_timeline.py's__main__block so redirected Windowspython -Iruns do not failtests/test_tool_stdout_encoding.py(tools/stage_timeline.pyis removed frommissing).PRESStimestamp regex ([0-9]+(?:\.[0-9]+)?) and makefirst_value()returnNonesafely for empty strings, leading commas (e.g.,1234), partial?hex tokens, or non-hex values instead of raisingValueError.encoding="utf-8-sig", errors="replace"and catchOSErrorinmain()to print a concise error line to stderr and return exit code2instead of a traceback.p["game"] == 3before reporting"story load (loading screen ended)"intimeline().tests/test_stage_timeline.py.Tested
python -I tests/test_stage_timeline.py -v->Ran 7 tests in 0.146s,OK(verified in a detachedupstream/mainworktree that the new test file fails before the fix:FAILED (failures=4, errors=2)).python -I tests/test_tool_stdout_encoding.py->tools/stage_timeline.pyis no longer inmissing(only pre-existing['tools/compute_heap_layout_census.py']fails).python -I tests/test_ci_registration.py->Ran 16 tests in 4.545s,OK.python -I tests/test_text_write_line_endings.py->Ran 3 tests in 12.772s,OK.python -I scripts/check_no_game_data.py tools/stage_timeline.py tests/test_stage_timeline.py-> exit0.python -I -m compileall -q tools/stage_timeline.py tests/test_stage_timeline.pyandgit diff --check-> clean.GPUs tested: n/a (CPU/stdlib Python tests on Windows 11 x64)
AI-assisted: yes
Checklist
needs rebase).🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.