Skip to content

Normalize Windows-style separators in PackagePath - #560

Open
DeviousCardi wants to merge 2 commits into
python:mainfrom
DeviousCardi:fix-528-windows-record-paths
Open

DeviousCardi wants to merge 2 commits into
python:mainfrom
DeviousCardi:fix-528-windows-record-paths

Conversation

@DeviousCardi

Copy link
Copy Markdown

Fixes #528.

Approach

The RECORD specification permits \ as a directory separator on Windows, while PackagePath is a PurePosixPath and treated those separators as literal filename characters. That made .name, .parent, .suffix, and .as_posix() differ between platforms for the same RECORD entry.

PackagePath now normalizes \ to / during construction, so RECORD paths are interpreted consistently everywhere. POSIX paths are unchanged because they contain no backslashes. The normalization is applied in both __new__ and __init__ to cover Python 3.11 (parsing in __new__) and 3.12+ (parsing in __init__).

Distribution.files() therefore returns PackagePath objects whose string and as_posix() forms are portable, while .locate() continues to resolve against the distribution's actual filesystem path.

Tests

Added unit coverage for backslash-only, mixed, absolute Windows (drive-letter), and unchanged POSIX paths, plus an integration test asserting Distribution.files() normalizes RECORD entries.

Run with the repository's documented checks:

.venv/bin/python -m pytest -q
.venv/bin/python -m ruff format --check .
.venv/bin/python -m ruff check .

Result: 160 passed, 1 skipped, 47 subtests passed; ruff format and lint clean.

AI disclosure

This change was prepared with AI assistance and reviewed by a human before submission.

The RECORD specification allows backslashes as directory separators on Windows. Normalize them to portable forward slashes when constructing PackagePath so name, parent, suffix, and as_posix() agree on every platform. Fixes python#528.
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.

PackagePath does not support Windows paths

1 participant