Repository navigation
Conversation
Signed-off-by: Sungmin Park <ryan040@korea.ac.kr>
This branch has not been deployed
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.
Description
Fixes #1391
The pre-check in
IntBuiltins.StrNode.doPIntrejected every int whose bit length was>=the bit length of10**limit. Ints from2**(b-1)up to10**limit - 1share that bit length but have onlylimitdigits, sostr(),repr()and f-strings raisedValueErrorfor them (with the default limit, every 4300-digit value from2**14284up). CPython raises only when the result has more digits than the limit (longobject.c#L2170-L2180).AS-IS
TO-BE
(matching CPython)
Changes
IntBuiltins.StrNode.doPInt, reject beforetoString()only ints whose bit length is greater than that of10**limit; those are at least2**b > 10**limit. Ints of exactly that bit length are left to the existing digit count aftertoString().test_str_with_max_str_digitstotests/test_int.py: with the limit at 4300,2**14284,10**4300 - 1and its negation convert withstr()andrepr()and round-trip throughint(), and10**4300and its negation still raiseValueError. It passes on CPython 3.12, 3.13 and 3.14.Testing
mx buildon darwin-aarch64 (master 3176851), thenmx graalpytest test_int(55 passed) and--tagged test_int(37 passed). Without the change, the new test fails atstr(2 ** 14284).mx checkstyle --primaryandmx eclipseformat --primaryreport nothing.