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
gh-99925: Fix inconsistency in json.dumps()
error messages
#99926
Conversation
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
@serhiy-storchaka Thanks for the review, makes sense I have made the requested changes; please review again. |
Thanks for making the requested changes! @serhiy-storchaka: please review the changes made to this pull request. |
LGTM. |
Fixes #99925.
When you try to serialize a
NaN
,inf
or-inf
withjson.dumps(..., allow_nan=False)
, the error messages are inconsistent, depending on whether you useindent
or not.That is because if you don't use
indent
, the encoding is done in C code here,but if you use
indent
, the encoding is done in pure Python code here, and the error messages are different between the two.This PR unifies the error messages, so that both now include the representation of the invalid value.