Skip to content

Reject non-normalized names in filename parsers - #1359

Open
kocaemre wants to merge 1 commit into
pypa:mainfrom
kocaemre:fix/reject-nonnormalized-filenames
Open

Reject non-normalized names in filename parsers#1359
kocaemre wants to merge 1 commit into
pypa:mainfrom
kocaemre:fix/reject-nonnormalized-filenames

Conversation

@kocaemre

@kocaemre kocaemre commented Aug 1, 2026

Copy link
Copy Markdown

Summary

  • Preserve the NormalizedName invariant for parsed wheel and sdist filenames.
  • Reject filename project names whose canonicalized value is not accepted by is_normalized_name.
  • Move the non-ASCII filename cases from accepted wheel examples to invalid filename coverage and add matching sdist coverage.

Closes #1350.

Verification

RED:

  • python3 -m pytest tests/test_utils.py::test_parse_wheel_filename_rejects_names_that_are_not_normalized -q failed before the fix with Failed: DID NOT RAISE <class 'packaging.utils.InvalidWheelFilename'>.

GREEN:

  • python3 -m pytest tests/test_utils.py -q → 79 passed
  • python3 -m pytest -q → 62425 passed, 427 deselected
  • python3 -m ruff check src/packaging/utils.py tests/test_utils.py → All checks passed
  • python3 -m ruff format --check src/packaging/utils.py tests/test_utils.py → 2 files already formatted
  • python3 -m py_compile src/packaging/utils.py tests/test_utils.py
  • git diff --check

Duplicate preflight

Signed-off-by: Emre K <110906681+kocaemre@users.noreply.github.com>
@sbidoul

sbidoul commented Aug 9, 2026

Copy link
Copy Markdown
Member

I believe the linked issues needs discussion before considering a PR.

@kocaemre

Copy link
Copy Markdown
Author

Thanks — moved the rationale/options to the linked issue for discussion: #1350 (comment)

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.

parse_wheel_filename can return a project name that fails is_normalized_name

2 participants