gh-134717: Allow overriding serialization of NaN and Infinity in json.encoder#134715
gh-134717: Allow overriding serialization of NaN and Infinity in json.encoder#134715krzyszti wants to merge 3 commits into
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 |
sharktide
left a comment
There was a problem hiding this comment.
self isn't defined here either
|
Also keep in mind that the C implementation will still be called if you override floatstr. |
|
This PR is stale because it has been open for 30 days with no activity. |
This change modifies the
json.encodermodule to permit customization of how special floating-point values (NaN,Infinity,-Infinity) are serialized. By introducing afloatstrfunction, developers can now define alternative representations for these values, such asnull,0, or custom strings, enhancing flexibility in JSON output.