Skip to content

Normalize backslash separators before resolving dot components - #78

Open
hakarrr wants to merge 2 commits into
thombashi:masterfrom
hakarrr:master
Open

hakarrr wants to merge 2 commits into
thombashi:masterfrom
hakarrr:master

Conversation

@hakarrr

@hakarrr hakarrr commented Oct 24, 2026

Copy link
Copy Markdown

sanitize_filepath(r"a\b\..\c.txt", platform="windows") leaves the .. component on Linux, whereas the equivalent slash-separated input becomes a\c.txt. The sanitizer already treats backslashes as separators, but only after calling the host's os.path.normpath.

Translate the separators before normalization so dot components are resolved consistently for both input styles. Drive splitting, component sanitization, output separators and the normalize=False path stay in place.

Added 26 cases covering mixed separators, ./.., string/Path inputs, Windows drive/UNC/root paths, unchanged paths and the normalization opt-out. On the unmodified base, 14 cases fail and 12 controls pass.

Validation on Linux:

  • Full suite: 4,196 passed, 14 existing platform skips, on CPython 3.9, 3.10, 3.11 and 3.12.
  • Combined line/branch coverage: 94.6%.
  • Configured Pyright, codespell and repository-wide Ruff formatting checks pass. Ruff check has 129 baseline diagnostics, exactly unchanged.
  • Wheel/sdist build, twine check and git diff checks pass.

Windows/macOS, Python 3.13/3.14 and PyPy CI were not run locally. Nine additional checks with the Windows path normalizer pass, but are not a substitute for the Windows CI job. Existing warnings remain.

Replace backslashes with forward slashes in normalized file paths.
Add tests for normalizing backslash separators in file paths across different platforms.

This branch has not been deployed

No deployments
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.

1 participant