gamedata_reader: fix --root filter, sanitize --out filenames, and write JSON atomically (GAMEDATA-READER-FILTER-AND-OUT-IO) #1557
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!1557
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/gamedata-reader-filter-and-out-io"
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
What
Fix
--rootfiltering, unsafe export filenames, and--outI/O handling intools/gamedata_reader.py:--outexport (_safe_stem,run):ET.iterparseexpands XML namespaces to Clark notation ({http://example.com/ns}Root), sof"{tag}_{name}.json"contained/and:and crashed withFileNotFoundError/OSError.[<>:"/\\|?*\x00-\x1f]) with_while leaving ordinary ASCII tag/file stems unchanged.--rootmissed valid documents without a matchingroot_hint(run):hint != root_filterdropped documents whoseroot_hintwas empty (e.g. a self-closing root after<!DOCTYPE ...>) or lacked the namespace prefix of a Clark-notation--rootfilter, and never verified the parsedtagagainstroot_filter.hintis non-empty and matches neitherroot_filternor its local name (root_filter.endswith("}" + hint)), and verifytag == root_filterafter parsing.--out, atomic LF-terminated writes, and accurate write error diagnostics (main,run):--outpaths withERROR: --out path must not be empty(exit2) instead of silently ignoring""or creating a whitespace-named folder.newline="\n", trailing"\n",file_mode.published_mode,replace_retry.replace), and report writeOSErrors asERROR: cannot write ...instead ofERROR: cannot read ....Claimed in the coordination issue as
GAMEDATA-READER-FILTER-AND-OUT-IO— verified 0 open PRs and 0 prior claims; unable to post a comment on#14because GitHub disabled commenting once#14reached its 2,500-comment cap (and no successor"Coordinating who works on what"issue is open yet).Testing
python3 -I -W error tests/test_gamedata_reader.py -v: 25/25 OK (including 3 new regression tests).python3 -I tests/test_text_write_line_endings.py: 3/3 OK.python3 -I scripts/check_no_game_data.py tools/gamedata_reader.py tests/test_gamedata_reader.py: clean.python3 -m compileall -q tools/gamedata_reader.py tests/test_gamedata_reader.py: clean.Mutation check against unpatched
main:tools/gamedata_reader.py: all 3 new tests fail onmain(FAILED (failures=3, errors=2)).AI-assisted: yes
GPUs tested: none (CPU-only XML reader tests on macOS; no GPU or game files needed)
Red/green: the PR's tests fail on main and pass with this PR (Linux, Python 3.13.18).
Targeted batch of 19 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)