Skip to content

Reject empty/invalid Tag components consistently - #1413

Open
Pitchfork-and-Torch wants to merge 1 commit into
pypa:mainfrom
Pitchfork-and-Torch:cook/tag-reject-empty-and-invalid-components
Open

Pitchfork-and-Torch wants to merge 1 commit into
pypa:mainfrom
Pitchfork-and-Torch:cook/tag-reject-empty-and-invalid-components

Conversation

@Pitchfork-and-Torch

Copy link
Copy Markdown

Summary

parse_tag() already raises InvalidTag for empty components, but Tag() accepted them (Tag('', 'none', 'any') → -none-any). Separately, only the interpreter was checked with str.isidentifier(), so tags like py3-none-any, and py3-none-any parsed successfully with junk in the platform field.

  • Tag.__init__ now rejects empty components
  • parse_tag validates abi and platform with isidentifier() like interpreter

Test plan

  • TestTag / TestParseTag (42 tests) pass

Tag() accepted empty interpreter/abi/platform while parse_tag rejected
them, and parse_tag allowed trailing junk like `py3-none-any,` because
only the interpreter was checked with str.isidentifier(). Validate all
three components in both paths.

@sylvesterkaczmarek sylvesterkaczmarek left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

str.isidentifier() is Python-identifier grammar, not compatibility-tag grammar. In particular it rejects a digit-leading ABI token, even though the compatibility-tag spec allows implementation-defined ABI hashes whose base64 text can start with a digit. Could this validate the actual tag grammar instead of identifier syntax?

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.

2 participants