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

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).

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.

5 participants