Skip to content

bink_names: read a streams JSON index saved with a UTF-8 BOM - #5877

Open
evilclanker9000 wants to merge 2 commits into
ItsNotRexed:mainfrom
evilclanker9000:deepseek/4-bink-names-bom
Open

evilclanker9000 wants to merge 2 commits into
ItsNotRexed:mainfrom
evilclanker9000:deepseek/4-bink-names-bom

Conversation

@evilclanker9000

Copy link
Copy Markdown
Contributor

tools/bink_names.py load_streams() opened a streams .json index with encoding="utf-8". Windows PowerShell 5.1 (Set-Content, Out-File) writes text files with a UTF-8 BOM, so an index a user saved that way ended in json.decoder.JSONDecodeError: Unexpected UTF-8 BOM and the tool exited with an error instead of naming the streams. Read the JSON branch with utf-8-sig, the same way world_build.py and world_names.py already read their input. The CSV branch is unchanged.

EGEN-BINK-NAMES-BOM.

Test

python -I tests/test_bink_names.py TestReportErrors.test_json_source_saved_with_a_utf8_bom_is_read

Before (tool unchanged): FAILED (errors=1) — json.decoder.JSONDecodeError: Unexpected UTF-8 BOM (decode using utf-8-sig): line 1 column 1 (char 0).
After: Ran 1 test in 0.016s / OK.

Full file: python -I tests/test_bink_names.py → Ran 34 tests, one failure that is already on upstream/main 561b65a8 without this change (test_unreadable_mount_directory_preserves_the_report expects the plain path, the OSError message repr's it — the subject of open #5760), and 33/34 otherwise. No GPU needed.

Notes

  • Scoped to the JSON branch only: the CSV path reports a wrong header as a clean one-line error, while the JSON path was a traceback-prone decoder exception.
  • Two commits: the root fix and the test that fails without it.

AI-assisted.

load_streams() opened the .json index with encoding=utf-8, so an index written by PowerShell 5.1 (which writes a BOM) ended in a JSONDecodeError. Use utf-8-sig, as world_build.py and world_names.py already do.
Fails on the previous commit with JSONDecodeError: Unexpected UTF-8 BOM; passes with utf-8-sig.
@kapitche

Copy link
Copy Markdown
Contributor

Tested 324856a merged with main 561b65a on Ubuntu (WSL2) / Python 3.12.16: pass

tests/test_bink_names.py: 34 run, 34 passed, 0 failed. Negative control: with tools/bink_names.py checked out from upstream/main, the new test_json_source_saved_with_a_utf8_bom_is_read errors (JSONDecodeError: Unexpected UTF-8 BOM), 34 run, 1 error. Diff is a one-line encoding change (utf-8 to utf-8-sig) plus the test; no other readers affected.

@ne1i

ne1i commented Nov 23, 2026

Copy link
Copy Markdown

Tested 324856ac on Linux, CPython 3.14, CPU only, synthetic inputs, merged onto main 867d922f: pass

  • python -I tests/test_bink_names.py: Ran 34 tests, OK. With only the non-test files reverted to main: FAILED (errors=1), so the new tests exercise the change.
  • compileall and scripts/check_no_game_data.py on the changed files: clean.

Independent check (not the author). Run by an AI agent (DeepSeek V4.1 Flash) and re-run by the orchestrating session (Claude Code) before posting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants