Repository navigation
Conversation
Wkhanex
reviewed
Oct 12, 2026
There was a problem hiding this comment.
The integer overflow case is fixed, but the same finite value passed through the accepted string input still renders as infinity: scientific(10**400) → 1.00 x 10⁴⁰⁰, while scientific("1" + "0" * 400) → +Inf. I reproduced both at this head. float(huge_integer_string) returns infinity rather than raising OverflowError, so the Decimal fallback is skipped for that form. Consider an integer-string regression and detecting that finite form before the float conversion. I ran these checks on Python 3.12 with English locale hooks; no full package test run.
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 #
Changes proposed in this pull request:
scientificfalls back toDecimalformatting whenfloat()overflows, so an integer larger than the float range no longer raisesOverflowErrorDecimalis only used on the overflow path10**400, its negative, a precision argument and precision0, plus0to pin the unchanged pathSame family as #420:
scientificconverts withfloat()first, which raisesOverflowErrorfor an integer beyond the float range and is not covered by theexcept (ValueError, TypeError)clause.After this change it returns
'1.00 x 10⁴⁰⁰'.Decimalis not used for all integers becauseformat(Decimal(0), ".2e")gives0.00e+2, which would breakscientific(0).