Skip to content

tools: print the plain path, not a repr'd one, in OSError messages (OLD-9861) - #1792

Open
Ch1mpleo wants to merge 1 commit into
ProjectLeonida:mainfrom
Ch1mpleo:carry/old-9861
Open

Ch1mpleo wants to merge 1 commit into
ProjectLeonida:mainfrom
Ch1mpleo:carry/old-9861

Conversation

@Ch1mpleo

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: OLD-9861 (#1608 (comment))

What and why

Carries forward old-pr/9861 (draft #128, preserving Salim Hammami's original commit) rebased onto current main. Prints the plain path instead of a
epr'd path in OSError messages in ools/bink_names.py, ools/opus_tags.py, and ools/world_names.py.

Tested

  • python -m compileall -q tools/bink_names.py tools/opus_tags.py tools/world_names.py — exit 0.
  • python -I tests/test_bink_names.py — 36 tests, OK.
  • python -I tests/test_opus_tags.py — 28 tests, OK.
  • python -I tests/test_world_names.py — 31 tests, OK.
  • python -I scripts/check_no_game_data.py tools/bink_names.py tools/opus_tags.py tools/world_names.py — exit 0.

GPUs tested: n/a (CPU-only Python tools & unit tests, Windows 11 x64, Python 3.14.7)

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled
    eeds rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a — no translator change)

@madvillain91 madvillain91 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Independent Windows 11 26H2 (26300.9711) check at 4811fd1 against main 98c2f77 (PR base 0d80bc5), using CPython 3.12.3 (python -I) and Git for Windows 2.56.0.windows.2. Existing suites pass (test_bink_names.py 36/36 in 0.685s, test_opus_tags.py 28/28 in 5.948s, test_world_names.py 31/31 in 0.489s), but a few issues stand out:

  1. In tools/bink_names.py:459, a.mount is a list[str] (action="append"). When error.filename is None, {error.filename or a.mount} prints a repr'd Python list with doubled backslashes on Windows -- reproduced locally as:
    bink_names: error: ['C:\\Users\\...\\m.xml']: Permission denied
    Joining ", ".join(a.mount) or omitting the path when error.filename is None (matching world_names.py) would avoid that.
  2. Other OSError handlers in the same main() functions still interpolate raw {error} / {e}: tools/bink_names.py lines 464 (load_streams), 469 (load_pins), and 483 (write), plus tools/opus_tags.py line 273 (load_names/load_dialogue).
  3. No regression tests were added asserting plain-path formatting on OSError.

@Ch1mpleo

Copy link
Copy Markdown
Contributor Author

Thanks for the thorough review @madvillain91! Pushed a follow-up commit (\903f45020) addressing all three points (keeping Salim Hammami's original commit intact):

  1. \ ools/bink_names.py: joined \�.mount\ with ", ".join(a.mount)\ when \�rror.filename\ is \None\ so it never prints a
    epr'd Python list.
  2. \ ools/bink_names.py\ and \ ools/opus_tags.py: updated the remaining \OSError\ handlers in \main()\ (\load_streams, \load_pins, \write, and \load_names/\load_dialogue) to format plain paths (\�rror.filename\ / \strerror).
  3. Added \ est_oserror_prints_plain_path_without_repr\ regression tests in \ ests/test_bink_names.py\ (37/37 OK), \ ests/test_opus_tags.py\ (29/29 OK), and \ ests/test_world_names.py\ (32/32 OK).

@OguzSoykan

Copy link
Copy Markdown
Contributor

Verified on native Windows at head 4811fd104: test_bink_names.py, test_opus_tags.py and test_world_names.py fail on main and pass here. Same change area as #128 (tool side) and the opposite direction from #1425 (test side).

Native Windows 10 Pro 19045, CPython 3.12, py -3.12 -I, checkout under a non-ASCII profile path (C:\Users\Oğuz\..., TEMP is the 8.3 alias C:\Users\OUZ~1\...). No game files.

AI-assisted (Claude Code).

@wavehs

wavehs commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Verified on main f107ae044 (macOS 27.2.1 arm64, Python 3.15.2). The diff applies cleanly. Reproducing the Windows failure on POSIX by pointing TMPDIR at a folder whose name contains a backslash (legal on POSIX; the tools then repr a filename with a doubled separator, exactly as a Windows path does):

Before (unmodified main): one failure per file — test_bink_names.py::test_unreadable_mount_directory_preserves_the_report, test_opus_tags.py::test_cli_reports_incomplete_directory_discovery, test_world_names.py::test_an_unreadable_subtree_does_not_replace_the_dictionary — each assertIn(blocked, stderr) against a ...back\\\\slash... line.

After: all three OK (Ran 36, Ran 28, Ran 31 tests).

Two coordination notes:

AI-assisted (verification only).

@github-actions github-actions Bot added the needs rebase Conflicts with the base branch: rebase it on main label Nov 28, 2026
@MoonEyes

Copy link
Copy Markdown
Collaborator

Blocker: With this PR merged onto main, tests/test_bink_names.py, tests/test_opus_tags.py and tests/test_world_names.py fail: they still expect the path in quotes in the error messages that this PR now prints plainly. Could you update those three tests (or keep the old form)?

Checked locally on main c1ecf04: the same test file(s) pass on main without this PR.

AI-assisted (Claude Code, Claude Opus 5.5), posted for MoonEyes.

@zmasi

zmasi commented Nov 29, 2026

Copy link
Copy Markdown
Contributor

#1792 | head 4811fd1 (merged cleanly onto origin/main 791899f) | Windows 11 (10.0.26200.9974), Python 3.12.10 | AI-assisted: yes

Independent Verification (Windows 11 — Post-Merge Test Regressions Found)

  • Diff & safety audit: Inspected 100% of the diff across tools/bink_names.py, tools/opus_tags.py, and tools/world_names.py. python -I scripts/check_no_game_data.py tools/bink_names.py tools/opus_tags.py tools/world_names.py passed (rc=0).
  • Red -> Green CLI verification on Windows 11:
    • Red (origin/main 791899f652): Triggering Win32 PermissionError (CreateFileW exclusive lock) and FileNotFoundError across bink_names.py, opus_tags.py, and world_names.py printed repr(filename) with single quotes and doubled Windows backslashes ([Errno 13] Permission denied: '<tempdir>\\bink_mnt\\locked.txt').
    • Green (#1792 + origin/main): All three tools printed the plain Windows path without quotes or doubled backslashes (bink_names: error: <tempdir>\bink_mnt\locked.txt: Permission denied, opus_tags: error: <tempdir>\opus_dir\0x12345678.ogg: Permission denied, ERROR: <tempdir>\sub_dir\missing_names.txt: No such file or directory).
  • Blocking post-merge test regressions when merged onto origin/main (791899f652):
    • Although git merge has zero textual conflicts, tests added on main since this branch's base still assert self.assertIn(repr(blocked), err.getvalue()), causing all three suites to fail (rc=1) after merge:
      1. python -I tests/test_bink_names.py -> FAILED (failures=1) at tests/test_bink_names.py:350 (test_unreadable_mount_directory_preserves_the_report)
      2. python -I tests/test_opus_tags.py -> FAILED (failures=1) at tests/test_opus_tags.py:381 (test_cli_reports_incomplete_directory_discovery)
      3. python -I tests/test_world_names.py -> FAILED (failures=1) at tests/test_world_names.py:49 (test_an_unreadable_subtree_does_not_replace_the_dictionary)
    • Updating self.assertIn(repr(blocked), err.getvalue()) -> self.assertIn(blocked, err.getvalue()) in tests/test_bink_names.py:350 (and the matching lines in test_opus_tags.py:381 and test_world_names.py:49) restores 41/41 test_bink_names.py (OK, 0.288s).
  • Non-blocking consistency note: Adjacent except (OSError, ...) handlers at tools/bink_names.py:478,483 (load_streams, load_pins) and tools/opus_tags.py:294-295 (load_names, load_dialogue) still interpolate {error} / {e} directly when an input CSV/JSON raises OSError.

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

Labels

needs rebase Conflicts with the base branch: rebase it on main

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants