awc_names: recognize BOM-prefixed and whitespace-prefixed word dictionaries #2449
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2449"
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 kirigayakazima on 2026-11-27T10:34:18Z.
Claimed in the coordination issue as: AWC-NAMES-WORD-DICTIONARY-DETECTION
What and why
An optional UTF-8 BOM could become part of the first plain-text word, cause a JSON file to fail parsing, or hide the opening brace of an extensionless hash dictionary. Skip a UTF-8 BOM in both input modes and detect the first non-whitespace character across read blocks. Explicit JSON inputs retain strict decoding. Tests cover a typed list, a plain word list and an extensionless hash dictionary with more than 8 KiB of leading whitespace.
Tested
Windows, Python 3.14.7. The regression reproduced on the parent and passed with the change.
python -I tests/test_awc_names.pygit diff --checkpassed.The integrated checkout passed 6,374 semantic tests across 500 files. CI's macOS job failed in the calibrated-texture replacement test, as it did on the unchanged main baseline.
GPUs tested: N/A (CPU-only synthetic tests).
AI-assisted: Yes.
Checklist
Imported from ubiquitarianism/leonida. Originally posted by MSedgeMC on 2026-11-27T15:04:07Z.
Review: COMMENTED
Verified on the PR branch: python3 -m unittest tests.test_awc_names -v -> 37 tests OK (1 skip), including the new BOM/whitespace-prefixed dictionary cases. Not approving yet: the branch is 606 commits behind current main and touches the same test file as PRs #2384/#2450, so a rebase is needed before reviewing the combined diff.
Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T06:52:21Z.
#2449 | head
484d1e7179(merged cleanly with main09c153948) |python -I tests/test_awc_names.py| red on main:FAILED (failures=2, errors=1)(test_word_dictionary_preamblesacrosswords.json, UTF-8 BOMhashdict, and UTF-8 BOMwords.txt) | green on PR+main:37 tests OK(-k test_word_dictionary_preambles:1 test OK) | Windows 11, Python 3.12.10 | AI-assisted: yesAudited
read_wordsintools/awc_names.py(utf-8-sigdecoding + chunked leading-whitespace scan for{beforeseek(0)plain-text fallback so.jsonword lists and BOM/whitespace-prefixed hash maps or word lists parse cleanly), and verified bothPR + main(09c153948) and a combinedmain + #2450 + #2449merge:git merge(ort) auto-mergedtools/awc_names.pyandtests/test_awc_names.pywith zero conflicts (38 tests OKintests/test_awc_names.py). Also passedtests/test_text_write_line_endings.py(3 OK),tests/test_runner_calls_all_tests.py(3 OK), andscripts/check_no_game_data.py.Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T15:14:26Z.
Red/green: classified READY by oreo-lot3 (red on main
b1619e0a3, green on head merged with main); head484d1e7179unchanged since 2026-11-27, before that run.Targeted batch (PR tests, tests importing the changed modules, docs tests, translator when touched) merged on main
d48a957bbin GitHub Actions: no new failure.AI-assisted (Claude Code, Claude Opus 5.5)