Skip to content

bink_names: accept UTF-8 BOMs in CSV inputs - #9369

Closed
danzig666 wants to merge 1 commit into
ProjectLeonida:mainfrom
danzig666:fix/bink-names-csv-bom
Closed

danzig666 wants to merge 1 commit into
ProjectLeonida:mainfrom
danzig666:fix/bink-names-csv-bom

Conversation

@danzig666

Copy link
Copy Markdown
Contributor

Summary

bink_names.py treated the UTF-8 BOM at the start of a CSV as part of its first header, so a valid stream report appeared to be missing source and a pin catalogue appeared to be missing offset. Read both CSV inputs with utf-8-sig so BOM-prefixed and plain files take the same validation path.

BUILD-BINK-NAMES-CSV-BOM claim

Verification

AI-assisted (Codex).

@abnalstlll-byte abnalstlll-byte left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent Windows Review

What changed:

  • tools/bink_names.py:
    • Uses encoding="utf-8-sig" in load_streams and load_pins.
    • Transparently strips UTF-8 byte order marks (\ufeff) often produced by Windows editors and Excel CSV exports, preventing header field misidentification (\ufeffsource != source).

Verification on Windows 11 host:

  • Ran python -I -m unittest discover -s tests -p test_bink_names.py -k test_cli_reads_records_from_all_three_sources: passes.
  • Clean diff: standard library only, no game files.

LGTM!

@GonZiin

GonZiin commented Nov 23, 2026

Copy link
Copy Markdown

Tested b3ff321 on Linux x86_64 (WSL2), Python 3.14, no GPU: pass. Ran tests/test_bink_names.py (34 OK; 2 errors against main's tools/bink_names.py), compileall and check_no_game_data. Note (not blocking): the JSON source open at tools/bink_names.py:144 still uses utf-8, so a BOM JSON still fails. AI-assisted (Claude Code).

@RAINighty

Copy link
Copy Markdown

Tested b3ff3219a merged with main 5d74c2723 (clean merge) on Windows 11 (10.0.26300), Python 3.13.15 in UTF-8 mode (PYTHONUTF8=1; venv with the pinned tests/requirements.txt), with llvm-mc 21.1.8 (AMDGPU) and SPIRV-Tools v2026.4 on PATH: the file stays red on one test that is already red on main.

  • python -I tests/test_bink_names.py: with this PR 34 tests, FAILED (failures=1); on main FAILED (failures=1). Both sides fail TestCli.test_unreadable_mount_directory_preserves_the_report (tests: normalize path matching for PermissionError on Windows in test_bink_names #8704 is an open PR for that test), so this PR neither causes nor fixes it; the added BOM cases pass.
  • Negative control: this PR's test with main's tools/bink_names.py: FAILED (failures=1, errors=2); the two extra errors are test_csv_inputs_accept_a_utf8_bom (streams.csv and pins.csv), so the new cases do catch the change.
  • Code not reviewed beyond running it. No GPU or game files.

AI-assisted (Claude Code).

@Matiux14

Copy link
Copy Markdown

Reviewed b3ff3219a (CPU only, Windows 11, CPython 3.15.2) against main 867d922f0.

  • python -m compileall -q tools/bink_names.py tests/test_bink_names.py -> exit 0
  • python -I tests/test_bink_names.py -k test_csv_inputs_accept_a_utf8_bom -> OK (new BOM test passes)
  • Full python -I tests/test_bink_names.py -> 1 failure, TestCli.test_unreadable_mount_directory_preserves_the_report, pre-existing on main (fails identically without this PR); with the PR the suite gained the new passing test (33 -> 34 tests).
  • python -I scripts/check_no_game_data.py tools/bink_names.py tests/test_bink_names.py -> exit 0
  • git diff --check main...pr-9369 -> clean

The PR switches CSV readers to encoding="utf-8-sig" so a UTF-8 BOM no longer pollutes the first header field, and adds the BOM case to the streams/pins loaders.

AI-assisted review.

@pablo-biasco-411953

Copy link
Copy Markdown

checked: #9369b3ff321 | with: PR diff applied on main 5d74c27, python -m pytest -q tests/test_bink_names.py | on: Windows 11, CPython 3.11.9, pytest 9.2.0, CPU only, no game files | result: pass, 1 failed, 33 passed, 44 subtests passed; no new failures against the same tests on main | agent: yes

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.

7 participants