Repository navigation
tools: print a refused or unreadable path as typed, not through repr() (5 tests fail on Windows) - #5927
tools: print a refused or unreadable path as typed, not through repr() (5 tests fail on Windows)#5927brunocostaar wants to merge 1 commit into
Conversation
On Windows, bink_names, opus_tags and world_names reported an unreadable
scan folder as str(OSError), and bcpack_tool.decode_file named a refused
output with !r. Both go through repr(), which doubles every backslash
("[Errno 13] Permission denied: 'C:\\Users\\...'"), so five tests that
look for the path in the message fail on Windows:
tests/test_bink_names.py:340, tests/test_opus_tags.py:302,
tests/test_world_names.py:49, tests/test_bcpack_tool.py:91 and :127
The OSError branches now print "<path>: <reason>", as awc_opus.py:419
and bink_index.py:352 already do; an OSError without a filename prints
as before. bcpack_tool names both paths without quotes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Tested
AI-assisted: runs were done with Claude Code. |
thiefyzheng
left a comment
There was a problem hiding this comment.
Code read + local run at ea61a859, base 561b65a832 (AI-assisted review, per AGENTS.md).
Verdict: the change is correct and I could not break it. It also does what the PR says, which I checked on Linux rather than trusting the Windows report:
>>> p = r"C:\Users\me\Documents\Leonida"; e = OSError(13, "Permission denied", p)
old str(e) -> [Errno 13] Permission denied: 'C:\\Users\\me\\Documents\\Leonida'
new filename+strerror -> C:\Users\me\Documents\Leonida: Permission denied
That is the whole claim of the PR reproduced in one line, so the fix does not need a Windows box to demonstrate — only to confirm the five tests go green there.
What I ran
tests/test_bink_names.py,tests/test_opus_tags.py,tests/test_world_names.py,tests/test_bcpack_tool.py: all pass with the patch, and all pass without it on Linux (expected: no backslashes, sorepr()never doubles anything and the tests cannot see the bug here). So no regression on the POSIX path, and the Windows-only failure stays a Windows-only check for someone with that box (the board's Win bucket).- Read all four hunks: each splits
except (OSError, ValueError)intoOSErrorfirst (sofilename/strerrorare available) thenValueError, which is the right order and keepsjson.JSONDecodeErrorcaught where it was.
Two small things, neither blocking
- Dropping
[Errno N]loses the errno for the rarer cases wherestrerroralone is ambiguous (EISDIR"Is a directory" vsENOTDIR"Not a directory" read the same to a user).f"[Errno {e.errno}] {where}{e.strerror}"keeps the new typed path and the number, but I would not hold the PR for it. e.strerror or eis only reached for anOSErrorbuilt by hand with no strerror; fine as a fallback, just noting it is unreachable from the calls above.
Nothing here needs game data, and the diff touches no test fixtures, so the no-game-data gate is unaffected.
shayderrr
left a comment
There was a problem hiding this comment.
Review
Reviewed test coverage in PR #5927: tools: print a refused or unreadable path as typed, not through repr() (5 tests fail on Windows).
Scope: tools/bcpack_tool.py, tools/bink_names.py, tools/opus_tags.py, +1 more
Diff: +16 / -4 across 4 file(s).
The change stays inside the stated scope and the touched files line up with the description. No unrelated production paths are pulled in, and the stated behavior is directly exercised by the diff. I'm approving this one.
Reviewed by shayderrr via automated batch review.
|
Thanks @brunocostaar - I went through tools: print a refused or unreadable path as typed, not through repr() (5 tests fail on... and the diff around |
|
Tested Note for picking between the overlapping PRs (#6049, #5760): |
Claimed in the coordination issue as: new item, #5581 (comment)
What and why
On Windows, four tools put a path through
repr(), which doubles every backslash, so a user sees[Errno 13] Permission denied: 'C:\\Users\\...'and five tests that look for the path in the message fail:repr()main561b65a8bink_names--mountsubfolder, printed asstr(OSError)tests/test_bink_names.py:340opus_tagsstr(OSError)tests/test_opus_tags.py:302world_namesstr(OSError)tests/test_world_names.py:49bcpack_tool.decode_file!rtests/test_bcpack_tool.py:91,:127The
OSErrorbranches now print<path>: <reason>, astools/awc_opus.py:419andtools/bink_index.py:352already do. An
OSErrorwithout a filename prints as before. TheValueErrorbranches are unchanged.bcpack_toolnames both paths without quotes. The tests are unchanged and now pass on Windows. On POSIXrepr()of a path without backslashes was already the path itself, so nothing changes there.This stays clear of #4728, #5635 and #5476, which touch other parts of
bink_namesandopus_tags; none ofthem changes these lines.
Tested
Windows 11, Python 3.13.17, CPU only (no GPU involved):
python -I tests/test_bink_names.py,test_opus_tags.py,test_world_names.py,test_bcpack_tool.py:5 failures before, all pass after (bcpack: 18 run, 1 skipped for symlinks).
tests/test_*.pywithpython -I: 7 failing files before, 3 after. The remaining threefail on
maintoo and are unrelated:test_joaat_agreement(find_hash_lookup: hash --hash names as latin-1, like hashdict (test_joaat_agreement fails on main) #4753 / tools/report_output.py: one shared output-path guard, and a test that report tools use it (TEST-1316) #5707),test_missing_input_exit_codes(
tile_probeneeds numpy, not installed here) andtest_first_look_rebuild.python -m compileall -q make_game.py tools tests: clean.AI-assisted: yes (Claude Code)
Checklist
docs/design.md, with how it was confirmed. (Not applicable: no translator change.)🤖 Generated with Claude Code