-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: json.decode fails for nums larger than sys.maxsize #34984
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 7 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
d22da4d
TST: removed xfail from json.decode(long int)
arw2019 46d05a3
added Object_newBigNum to JSONtoObj.c
arw2019 cce506c
bug: changed PyLong_FromUnicode to PyLong_FromUnicodeObject
arw2019 a0a6846
updated JSONObjectDecoder
arw2019 c60cabc
added case DECODE_BIGNUM to decode_numeric
arw2019 3c91879
fixed if statement to reset overflowing int
arw2019 e4eb0af
removed debug statement
arw2019 f1a3e0a
added cStr variable to PyObjectDecoder
arw2019 f3894e5
added conversion intValue->string
arw2019 bfe6595
implemented cStr storage of long int for JSON decoding
arw2019 c18f685
implemented cStr storage of long int for JSON decoding
arw2019 4027704
updated ujson header file
arw2019 e002cc4
updated ujson header file
arw2019 aa74e5a
styling changes to minimize diff
arw2019 60cccc8
removed xfail test (fixed in this PR)
arw2019 6fd68ef
fixed xfail test
arw2019 74980f4
freed ds->cStr at the end of JSON_DecodeObject
arw2019 618f97f
TST: updated test
arw2019 eeea214
fixed Overflow check in ultrajsondec.c
arw2019 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this works generally. If you want a reference for overflow detection try looking at the python implementation of PyLong_AsLongLongAndOverflow
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like this might be ok because overflowLimit is adjusted earlier on depending on whether the number is positive or negative (in line 140
overflowLimit
gets changed if intValue came with a minus sign):pandas/pandas/_libs/src/ujson/lib/ultrajsondec.c
Line 128 in 0159cba
But I'm down to rewrite this part to follow the PyLong_AsLongLongAndOverflow implementation:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem is if
intValue*10ULL + newDigit
overflows than the comparison tooverflowLimit
is a moot point because you've already hit undefined behavior with the former