tests: assert the PermissionError filename as OSError renders it (TEST-WIN-PERMERR-REPR) #1425
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1425"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ubiquitarianism/leonida. Originally posted by thiefyzheng on 2026-11-24T23:56:17Z.
What
One line in each of three test files:
self.assertIn(blocked, err.getvalue())→self.assertIn(repr(blocked), err.getvalue()).Why
The finding is @GTAVIB4GTAVI's (coordination issue #14, 23:34:10Z): the three unreadable-directory tests mock
os.walk'sonerrorwithPermissionError(13, "Permission denied", blocked)and assert the path appears in the tool's stderr. The tools printERROR: {e}—tools/world_names.py:671,tools/bink_names.py:459,tools/opus_tags.py:278— andstr(OSError)renders.filenamewithrepr(): quoted, backslashes doubled. On Windows each of the three assertions failed on the actual repr'd line; on Linux the paths contain no backslashes, so the files pass there and the defect was invisible to the Linux CI. The assertion now comparesrepr(blocked)— the exact rendering under test — which passes on both platforms.This is the finding's first suggested form ("compare the value against the error's rendered filename"). Its alternative — the tools printing the path unquoted, as
tools/awc_manifest.py:268andtools/bink_index.py:438already do — would change three tools' stderr, and is a tools/ change rather than this one; happy to do that instead if a reviewer prefers the tool-side behavior.Corroboration: sibling tests with the same assertion shape pass on Windows because their tools print the path unquoted (
test_awc_manifest.py:312→tools/awc_manifest.py:268;test_bink_index.py:339), andtest_awc_opus.py:435-436asserts only the basename andstrerror, which the repr'd line contains — so exactly these three tests fail, as the finding said.What I ran
Windows 11 (Python 3.12.10), before (hub main
507029d1e): one named failure per file, at the finding's exact lines —test_world_names.py:49(1 of 31),test_bink_names.py:340(1 of 36),test_opus_tags.py:337(1 of 28); each assertion shows the plain path missing from the repr'd stderr line (quoted in the claim thread). After: all three files OK — 31/36/28 tests. Linux (CPython 3.13): before and after, all three files OK with identical counts, so the fix does not change Linux behavior. The patch was applied byte-identically on both platforms;scripts/check_no_game_data.pyclean.Not run
Not run under the repo's full CI suites (workflows will cover these files on both platforms); the tool-side alternative was deliberately not implemented.
AI-assisted: a pi coding agent operated by the repo contributor ran the Windows reproduction and both-platform verification; the finding is @GTAVIB4GTAVI's.
Imported from ubiquitarianism/leonida. Originally posted by whoalin1 on 2026-11-25T03:38:32Z.
Independent confirmation on native Windows 11 (Python 3.14): clean
origin/main3ff2a2adcfails exactly these three tests —tests/test_bink_names.py::TestCli::test_unreadable_mount_directory_preserves_the_report,tests/test_world_names.py::ManifestEnumerationTest::test_an_unreadable_subtree_does_not_replace_the_dictionary,tests/test_opus_tags.py::TestFolder::test_cli_reports_incomplete_directory_discovery. Root cause matches the PR description:str(PermissionError)renders the filename with repr-escaped backslashes on Windows, so the single-backslash path never matches stderr. This means thewindows-latestCIcheckleg has very likely been red since ~Nov 23. Verified standalone viapy -3.14 -I tests/test_bink_names.py→FAILED (failures=1). Therepr(blocked)assertion is the right fix (asserting the escaped form keeps coverage on both platforms).Imported from ubiquitarianism/leonida. Originally posted by Mby159 on 2026-11-25T08:24:29Z.
Independent check on native Windows 11, because the failure this starts from comes from
repr()doubling the backslashes in a Windows path.This PR and #128 are the two sides of the same item, and they cannot both land. #128 changes the three tools; this PR changes the three tests. Whichever lands second makes the three files fail again. #128 is open (a draft carried over from the old repository), and this PR's description offers the tool-side option but does not reference #128.
Measured on current
main(3f81d46ac), each tree a clean checkout plus the PR diff applied withgit apply(#128 @82bdc54f, #1425 @04b6b2ee; Windows 11 x64 10.0.29712, CPython 3.13.17, standard library only, no game files, no GPU):tests/test_world_names.pytests/test_bink_names.pytests/test_opus_tags.pymainmain+ #128main+ #1425main+ #1425 + #128The three failures on
mainare the three this PR targets:str(PermissionError)renders the filename withrepr(), so the path in the message has doubled backslashes and the plain path is not in the text. With both patches applied the failure is the same assertion in the opposite direction - the message holds the plain path, sorepr(path)is no longer in it.Two notes for the reviewer:
tools/awc_manifest.py,tools/awc_markers.py,tools/awc_opus.py, andtools/bink_names.pyitself at its--outcheck). #128 changes only the three tools; this PR changes only the three tests. Which side to take is the reviewer's call - I am only reporting that both are open and mutually exclusive.I ran the three files named above, and the 20 standard-library test files under
tests/whose source mentionsworld_names,bink_names,opus_tags,awc_manifest,awc_markersorbink_index(20 run, 0 failures; that set includes the three files above) on the tree with #128 applied. Not run: Linux, the CI workflows, the translator suite, and a full pass over all 535 standard-library test files.AI-assisted.
Imported from ubiquitarianism/leonida. Originally posted by DeadlyChirp on 2026-11-25T15:16:11Z.
Tested on Windows 11, Python 3.12.10. I merged
04b6b2ee4onto upstream main (merge commit f173f1485).python -I tests/test_bink_names.pypython -I tests/test_opus_tags.pypython -I tests/test_world_names.pyOn main, each test fails the same way: the expected path is not found in
[Errno 13] permission denied: 'C:\Users\...\blocked', because OSError prints the filename as a repr with doubled backslashes.Note for whoever merges: #128 and #1792 take the other route and change the tools to print the plain path. If one of those lands, the assertions here may need to match the new output.
(AI-assisted test run; output checked by hand.)
Imported from ubiquitarianism/leonida. Originally posted by thiefyzheng on 2026-11-25T19:56:36Z.
Noting for whoever merges, per @Mby159 and @DeadlyChirp: this PR (test side) and #128 / #1792 (tool side, print the plain path) fix the same three Windows failures and cannot both land, because whichever lands second makes the three files fail again. Either is fine with us. If #128 or #1792 is chosen, close this PR; if this one is chosen, #128 should be closed or rebased to drop the three tool changes. Maintainer's call.
AI-assisted (Claude Code).
Imported from ubiquitarianism/leonida. Originally posted by OguzSoykan on 2026-11-25T20:14:22Z.
Verified on native Windows at head
04b6b2ee4:test_bink_names.py,test_opus_tags.pyandtest_world_names.pyfail onmain(the expected path is the plain one, the message carries the repr with doubled backslashes) and pass here. The tool-side fixes #128 and #1792 also make all three pass on this machine; as noted in the coordination issue, the test-side and tool-side fixes go in opposite directions, so only one side should be merged.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 aliasC:\Users\OUZ~1\...). No game files.AI-assisted (Claude Code).
Imported from ubiquitarianism/leonida. Originally posted by wavehs on 2026-11-26T18:45:16Z.
The tool-side alternative you offered already exists as #1792 (Ch1mpleo, claimed as OLD-9861, rebased onto current main): it makes all three tools print
{e.filename or <arg>}: {e.strerror or e}, so the path is plain and unquoted, likeawc_manifest.py:268andbink_index.py:438that you cite as corroboration.The two cannot both land: this PR asserts the repr rendering, and #1792 changes that rendering to the plain path, so whichever lands second must rewrite these three assertions.
I would take #1792:
C:\\Users\\...in a message is the defect.mainf107ae044: with a backslash inTMPDIRthe three files fail on unmodified main and areOKwith that diff (36/28/31 tests).Your reproduction and the before/after numbers are solid, and the finding is real; this is only about which side of the contract changes. If the coordinator prefers the test-side change, then #1792 needs a rebase afterwards — but my vote is to close this one in favour of #1792.
AI-assisted (review only).
Imported from ubiquitarianism/leonida. Originally posted by Andretuta on 2026-11-27T06:24:42Z.
I reproduced the path assertion failure in all three files on native Windows with CPython 3.13.14 and no NumPy at
maind1dff7949. The reported paths had escaped backslashes, and the assertions expected the raw paths. With04b6b2ee4in the local CI integration,test_bink_names.pypassed 36/36,test_opus_tags.py28/28 andtest_world_names.py31/31 under #2193's two-worker runner.AI-assisted testing.