← 输入框|github.com|刷新
Skip to content

Use the integer index protocol for Version subscripts - #508

Merged
tomschr merged 2 commits into
python-semver:masterfrom
shrohan2003:fix/version-index-protocol
Nov 9, 2026
Merged

tomschr merged 2 commits into
python-semver:masterfrom
shrohan2003:fix/version-index-protocol

Conversation

@shrohan2003

Copy link
Copy Markdown
Contributor

Indexing a Version with an object that implements Python's integer index protocol raises an AttributeError about a missing stop attribute. Unsupported keys such as None leak the same implementation detail.

Normalize integer keys and slice bounds using the index protocol. Keep the existing IndexError for negative or undefined version parts. Tests cover custom integer indices, slice bounds and invalid keys.

@tomschr tomschr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you @shrohan2003 for your contribution! Much appreciated! 👍❤️

Ready to be merged. 🚀

@tomschr
tomschr merged commit 9f6894d into python-semver:master Nov 9, 2026
17 checks passed
@shrohan2003

Copy link
Copy Markdown
Contributor Author

Thanks for reviewing and merging this, @tomschr!

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