tests: assert the PermissionError filename as OSError renders it (TEST-WIN-PERMERR-REPR) #1425

Open
github-bot wants to merge 1 commit from github-bot/gh-1425 into main AGit
Owner

@⁠thiefyzheng on GitHub · 2026-11-24 23:56 UTC · original
thiefyzheng:fix/test-permerr-repr → main · +3 −3 · 3 files · 1 commits · open

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's onerror with PermissionError(13, "Permission denied", blocked) and assert the path appears in the tool's stderr. The tools print ERROR: {e} — tools/world_names.py:671, tools/bink_names.py:459, tools/opus_tags.py:278 — and str(OSError) renders .filename with repr(): 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 compares repr(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:268 and tools/bink_index.py:438 already 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), and test_awc_opus.py:435-436 asserts only the basename and strerror, 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.py clean.

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.

**@⁠thiefyzheng** on GitHub · 2026-11-24 23:56 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1425) `thiefyzheng:fix/test-permerr-repr` → `main` · +3 −3 · 3 files · 1 commits · open ## 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`'s `onerror` with `PermissionError(13, "Permission denied", blocked)` and assert the path appears in the tool's stderr. The tools print `ERROR: {e}` — `tools/world_names.py:671`, `tools/bink_names.py:459`, `tools/opus_tags.py:278` — and `str(OSError)` renders `.filename` with `repr()`: 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 compares `repr(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:268` and `tools/bink_index.py:438` already 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`), and `test_awc_opus.py:435-436` asserts only the basename and `strerror`, 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.py` clean. ## 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.
Three unreadable-directory tests compared the plain path against the
captured stderr, but the tools print str(exc), whose .filename is rendered
with repr(): quoted, backslashes doubled. On Windows each file failed that
one assertion; on Linux the path never contains backslashes so they passed.
The assertions now compare repr(blocked), the exact rendering under test.

The finding is GTAVIB4GTAVI's (coordination issue #14, 23:34:10Z).

AI-assisted.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:50:59 +00:00
Author
Owner

@⁠whoalin1 on GitHub · 2026-11-25 03:38 UTC · original

Independent confirmation on native Windows 11 (Python 3.14): clean origin/main 3ff2a2adc fails 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 the windows-latest CI check leg has very likely been red since ~Nov 23. Verified standalone via py -3.14 -I tests/test_bink_names.py → FAILED (failures=1). The repr(blocked) assertion is the right fix (asserting the escaped form keeps coverage on both platforms).

**@⁠whoalin1** on GitHub · 2026-11-25 03:38 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1425#issuecomment-7152106363) Independent confirmation on native Windows 11 (Python 3.14): clean `origin/main` `3ff2a2adc` fails 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 the `windows-latest` CI `check` leg has very likely been red since ~Nov 23. Verified standalone via `py -3.14 -I tests/test_bink_names.py` → `FAILED (failures=1)`. The `repr(blocked)` assertion is the right fix (asserting the escaped form keeps coverage on both platforms).
Author
Owner

@⁠Mby159 on GitHub · 2026-11-25 08:24 UTC · original

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 with git apply (#128 @ 82bdc54f, #1425 @ 04b6b2ee; Windows 11 x64 10.0.29712, CPython 3.13.17, standard library only, no game files, no GPU):

tree tests/test_world_names.py tests/test_bink_names.py tests/test_opus_tags.py
main 31 run, 1 failure 36 run, 1 failure 28 run, 1 failure
main + #128 31 run, OK 36 run, OK 28 run, OK
main + #1425 31 run, OK 36 run, OK 28 run, OK
main + #1425 + #128 31 run, 1 failure 36 run, 1 failure 28 run, 1 failure

The three failures on main are the three this PR targets: str(PermissionError) renders the filename with repr(), 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, so repr(path) is no longer in it.

Two notes for the reviewer:

  • The plain-path form is what other tools in the repository already print (tools/awc_manifest.py, tools/awc_markers.py, tools/awc_opus.py, and tools/bink_names.py itself at its --out check). #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.
  • The same conflict was already reported in the coordination issue for #128 against the earlier test-side PR (#763); this PR is the current test-side one.

I ran the three files named above, and the 20 standard-library test files under tests/ whose source mentions world_names, bink_names, opus_tags, awc_manifest, awc_markers or bink_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.

**@⁠Mby159** on GitHub · 2026-11-25 08:24 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1425#issuecomment-7156987580) 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 with `git apply` (#128 @ `82bdc54f`, #1425 @ `04b6b2ee`; Windows 11 x64 10.0.29712, CPython 3.13.17, standard library only, no game files, no GPU): | tree | `tests/test_world_names.py` | `tests/test_bink_names.py` | `tests/test_opus_tags.py` | |---|---|---|---| | `main` | 31 run, 1 failure | 36 run, 1 failure | 28 run, 1 failure | | `main` + #128 | 31 run, OK | 36 run, OK | 28 run, OK | | `main` + #1425 | 31 run, OK | 36 run, OK | 28 run, OK | | `main` + #1425 + #128 | 31 run, 1 failure | 36 run, 1 failure | 28 run, 1 failure | The three failures on `main` are the three this PR targets: `str(PermissionError)` renders the filename with `repr()`, 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, so `repr(path)` is no longer in it. Two notes for the reviewer: - The plain-path form is what other tools in the repository already print (`tools/awc_manifest.py`, `tools/awc_markers.py`, `tools/awc_opus.py`, and `tools/bink_names.py` itself at its `--out` check). #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. - The same conflict was already reported in the coordination issue for #128 against the earlier test-side PR (#763); this PR is the current test-side one. I ran the three files named above, and the 20 standard-library test files under `tests/` whose source mentions `world_names`, `bink_names`, `opus_tags`, `awc_manifest`, `awc_markers` or `bink_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.*
Author
Owner

@⁠DeadlyChirp on GitHub · 2026-11-25 15:16 UTC · original

Tested on Windows 11, Python 3.12.10. I merged 04b6b2ee4 onto upstream main (merge commit f173f1485).

test main this PR
python -I tests/test_bink_names.py FAILED (failures=1) OK
python -I tests/test_opus_tags.py FAILED (failures=1) OK
python -I tests/test_world_names.py FAILED (failures=1) OK

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

**@⁠DeadlyChirp** on GitHub · 2026-11-25 15:16 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1425#issuecomment-7166572516) Tested on Windows 11, Python 3.12.10. I merged 04b6b2ee4 onto upstream main (merge commit f173f1485). | test | main | this PR | |---|---|---| | `python -I tests/test_bink_names.py` | FAILED (failures=1) | OK | | `python -I tests/test_opus_tags.py` | FAILED (failures=1) | OK | | `python -I tests/test_world_names.py` | FAILED (failures=1) | OK | On 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.)
Author
Owner

@⁠thiefyzheng on GitHub · 2026-11-25 19:56 UTC · original

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

**@⁠thiefyzheng** on GitHub · 2026-11-25 19:56 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1425#issuecomment-7172972613) 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).
Author
Owner

@⁠OguzSoykan on GitHub · 2026-11-25 20:14 UTC · original

Verified on native Windows at head 04b6b2ee4: test_bink_names.py, test_opus_tags.py and test_world_names.py fail on main (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 alias C:\Users\OUZ~1\...). No game files.

AI-assisted (Claude Code).

**@⁠OguzSoykan** on GitHub · 2026-11-25 20:14 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1425#issuecomment-7173379156) Verified on native Windows at head `04b6b2ee4`: `test_bink_names.py`, `test_opus_tags.py` and `test_world_names.py` fail on `main` (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 alias `C:\Users\OUZ~1\...`). No game files. AI-assisted (Claude Code).
Author
Owner

@⁠wavehs on GitHub · 2026-11-26 18:45 UTC · original

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, like awc_manifest.py:268 and bink_index.py:438 that 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:

  • The doubled, quoted path is what the player or contributor sees in the tool's error, not just a test inconvenience; C:\\Users\\... in a message is the defect.
  • It fixes the same three Windows failures without teaching the tests to expect the broken spelling.
  • I verified #1792 on main f107ae044: with a backslash in TMPDIR the three files fail on unmodified main and are OK with 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).

**@⁠wavehs** on GitHub · 2026-11-26 18:45 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1425#issuecomment-7200813989) 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, like `awc_manifest.py:268` and `bink_index.py:438` that 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: - The doubled, quoted path is what the player or contributor sees in the tool's error, not just a test inconvenience; `C:\\Users\\...` in a message is the defect. - It fixes the same three Windows failures without teaching the tests to expect the broken spelling. - I verified #1792 on `main` `f107ae044`: with a backslash in `TMPDIR` the three files fail on unmodified main and are `OK` with 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).
Author
Owner

@⁠Andretuta on GitHub · 2026-11-27 06:24 UTC · original

I reproduced the path assertion failure in all three files on native Windows with CPython 3.13.14 and no NumPy at main d1dff7949. The reported paths had escaped backslashes, and the assertions expected the raw paths. With 04b6b2ee4 in the local CI integration, test_bink_names.py passed 36/36, test_opus_tags.py 28/28 and test_world_names.py 31/31 under #2193's two-worker runner.

AI-assisted testing.

**@⁠Andretuta** on GitHub · 2026-11-27 06:24 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1425#issuecomment-7211502093) I reproduced the path assertion failure in all three files on native Windows with CPython 3.13.14 and no NumPy at `main` `d1dff7949`. The reported paths had escaped backslashes, and the assertions expected the raw paths. With `04b6b2ee4` in the local CI integration, `test_bink_names.py` passed 36/36, `test_opus_tags.py` 28/28 and `test_world_names.py` 31/31 under #2193's two-worker runner. AI-assisted testing.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1425/head:github-bot/gh-1425'
git switch 'github-bot/gh-1425'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1425'
git switch 'github-bot/gh-1425'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1425'
git switch 'github-bot/gh-1425'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1425'
git switch 'main'
git merge --squash 'github-bot/gh-1425'
git switch 'main'
git merge --ff-only 'github-bot/gh-1425'
git switch 'main'
git merge 'github-bot/gh-1425'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.