Make Windows CI green: cross-platform path/regex/separator fixes (28 failures → 0)#65
Merged
Merged
Conversation
…eparator/encoding gotchas Applies the cross-platform-python protocol to the remaining Windows-only failures (all green on Linux/macOS, all failing on Windows): - naming.py + paths.py: the path-template builders compiled their regexes (named capture groups) via safe_compile, which re.escape's on Windows and corrupted the groups (same bug class as the filter_regex fix). Reverted all 7 sites to re.compile; literal text + separators are already re.escape'd, so this is a valid regex on every OS. (Matches the historical note in naming.py.) - filesys.py: replaced POSIX-only os.getuid() (AttributeError on Windows) with the cross-platform getpass.getuser() for the per-user temp dir. - util.not_a_mac_junk_path: split on BOTH separators (zip paths use '/', but os.path.sep is '\\' on Windows, so '__MACOSX' was missed there). - Made the platform-fragile doctests OS-independent (process_path, safe_compile); documented safe_compile as path-template-only (never for general regexes). Mac/Linux: full suite + doctests stay green (400 passed). Claude-Session: https://claude.ai/code/session_019bFtivmtdcXDoCQt3B9gGp
…-rootdir + test separators
- naming.template_to_pattern: regex-escape the LITERAL segments of a template (not
just substitute fields). A template that is/contains a real path has backslashes
on Windows; compiling them unescaped raised `re.error: incomplete escape \U`
(FileSysCollection key patterns, mk_dirs, subfolder stores, etc.). This is the
correct cross-platform fix (mirrors KeyTemplate._compile_regex); it also fixes a
latent bug where a literal '.' matched any character.
- filesys.ensure_slash_suffix(''): keep an empty prefix empty. It was returning a
bare separator, which prepended to absolute keys yields '\C:\Users\...' (invalid
on Windows, OSError 22) -- e.g. Files("") in dol.misc.get_obj.
- test_process_path: build the temp path from components, not "foo/bar" (abspath
normalizes '/'->'\\' on Windows, breaking the equality).
- mk_pattern_from_template_and_format_dict doctest: assert on matching behavior, not
a hand-counted-backslash pattern string (was OS-fragile and internally inconsistent).
Mac/Linux: full suite + doctests green (400 passed).
Claude-Session: https://claude.ai/code/session_019bFtivmtdcXDoCQt3B9gGp
…Windows failure)
The affix codec stripped/added a literal "/" while the dir paths end with os.sep
('\\' on Windows), so stores["folder1"] built a mixed-separator inner key
'...\folder1/' -> KeyError on Windows. Strip os.path.sep instead. Also make the
test's expected Files key OS-agnostic (os.path.join, not "subfolder/apple.p").
No-ops on POSIX (os.sep == '/'); full suite stays green (400 passed).
Claude-Session: https://claude.ai/code/session_019bFtivmtdcXDoCQt3B9gGp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Brings dol's Windows CI from 28 failures to 0 (Linux/macOS were already green;
all fixes are no-ops or improvements there). Applies the cross-platform-Python
discipline: abstract over the OS, never hardcode separators, and never route a
path through regex-escaping (or a regex through path-escaping).
Regex ⟷ path conflation (the
filter_regexbug class, finished off)naming.py+paths.py: the path-template builders compiled their regexes(named capture groups) via
safe_compile, whichre.escapes on Windows andcorrupted the groups. Reverted all 7 sites to
re.compile(matches the historicalnote in
naming.py).naming.template_to_pattern: nowre.escapes the literal template segments(a template that is/contains a real path has backslashes →
re.error: incomplete escape \U). MirrorsKeyTemplate._compile_regex; also fixes a latent bug where aliteral
.matched any character.util.safe_compile: documented as path-template-only (never for generalregexes), with an OS-independent doctest.
POSIX-only API
filesys.py:os.getuid()(AttributeError on Windows) → cross-platformgetpass.getuser()for the per-user temp dir.Separators / empty paths
util.not_a_mac_junk_path: split on both separators (zip paths use/, butos.path.sepis\on Windows, so__MACOSXwas missed).filesys.ensure_slash_suffix(""): keep an empty prefix empty — it wasreturning a bare separator, which prepended to absolute keys yields
\C:\Users\...(invalid on Windows,
OSError 22); e.g.Files("")indol.misc.get_obj.filesys.subfolder_stores: strip the nativeos.sep, not a hardcoded/(mixed-separator
...\folder1/→ KeyError on Windows).Tests / doctests
process_path,mk_pattern_from_template_and_format_dict,test_process_path,test_subfolder_stores) — asserting behavior oros.path.join, not hand-countedbackslashes or literal
/.Verification: Windows CI 400 passed, 0 failed (was 28 failed); macOS/Linux
full suite + doctests stay green (400 passed). Builds on #64 (the
filter_regexfix).https://claude.ai/code/session_019bFtivmtdcXDoCQt3B9gGp