Repository navigation
Keep whole numbers finite when they do not fit in a float - #452
Open
ShamikOfficial wants to merge 2 commits into
Open
ShamikOfficial wants to merge 2 commits into
ShamikOfficial wants to merge 2 commits into
Conversation
float() raised OverflowError for large ints and reported the same digit string as infinity. Co-authored-by: Cursor <cursoragent@cursor.com>
for more information, see https://pre-commit.ci
Author
|
I don't have permission to add labels. Please add |
Wkhanex
reviewed
Oct 12, 2026
Wkhanex
left a comment
There was a problem hiding this comment.
The huge integer and decimal-string controls pass, but this head defines _nonfinite_float twice with identical bodies. I confirmed two top-level definitions in the AST of src/humanize/number.py; Python silently overwrites the first definition with the second. Please remove the duplicate before merging so there is one implementation to maintain and no redefinition lint finding. I also executed scientific/apnumber controls for 10**400 and its decimal string; both remained finite and exact. AI-assisted review on Python 3.12 with English locale hooks, not the full package suite.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #419
float()was used to test for NaN and infinity. For an integer larger than the float range that raisesOverflowError. For the same number written as a digit string,float()returns infinity, so the value was reported as+Inf.Whole numbers are now treated as finite. Scientific notation for integers that do not fit in a float is formatted with
Decimal, so it does not overflow.Tested with
pytest tests/test_number.py(242 passed).