Skip to content

Propagate int-max-str-digits ValueError#1155

Merged
notatallshaw merged 3 commits intopypa:mainfrom
notatallshaw:fix/valueerror-propagation
Apr 11, 2026
Merged

Propagate int-max-str-digits ValueError#1155
notatallshaw merged 3 commits intopypa:mainfrom
notatallshaw:fix/valueerror-propagation

Conversation

@notatallshaw
Copy link
Copy Markdown
Member

Fixes #1154

Let the CPython int-max-str-digits ValueError propagate from Version() instead of converting it to InvalidVersion.

@notatallshaw notatallshaw force-pushed the fix/valueerror-propagation branch 3 times, most recently from 8476666 to 4378118 Compare April 10, 2026 22:11
@notatallshaw notatallshaw force-pushed the fix/valueerror-propagation branch from 4378118 to ae1a810 Compare April 10, 2026 22:11
Comment thread src/packaging/version.py
@@ -405,7 +405,13 @@ def __init__(self, version: str) -> None:
try:
self._release = tuple(map(int, version.split(".")))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We could keep version.split’s result and use that instead of splitting again.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I tried that and it causes a minor slow down of simple version construction.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Interesting, do you know why? Is it because it keeps around the reference for a bit longer?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Not a blocker by the way

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I can only speculate here, but yeah, it seems like storing a value and then accessing it has a measurable performance impact at the level of optimization we're at now.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It still gets stored, though - the only difference should be that the ref lives longer (and gets bumped one more pair of times, probably). Unless it can reduce this (not impossible, but unlikely - numpy can do this sort of thing on unix but not windows).

I wonder if del'ing the variable afterwords would affect it.

@notatallshaw notatallshaw merged commit 06c6555 into pypa:main Apr 11, 2026
57 checks passed
This was referenced Apr 13, 2026
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.

Oversized numeric components raise ValueError instead of InvalidVersion / InvalidSpecifier in packaging 26.0

2 participants