-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
gh-134717: Allow overriding serialization of NaN and Infinity in json.encoder #134715
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
base: main
Are you sure you want to change the base?
Conversation
This change can allow the programmer to override Nan/Infinity/-Infinity to be not only NaN but null, 0 or whatever they want it to be.
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
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.
@krzyszti
The news entry here is in the wrong place and format. Please move it to /next/Library/ and use blurb
or blurb it
to create the entry. The content {of the news entry} looks fine though
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.
self
isn't defined here either
Also keep in mind that the C implementation will still be called if you override floatstr. |
This change modifies the
json.encoder
module to permit customization of how special floating-point values (NaN
,Infinity
,-Infinity
) are serialized. By introducing afloatstr
function, developers can now define alternative representations for these values, such asnull
,0
, or custom strings, enhancing flexibility in JSON output.