Use strict float handling in JSON functions by rpkilby · Pull Request #5265 · encode/django-rest-framework (original) (raw)
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 andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Conversation4 Commits7 Checks0 Files changed
Conversation
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
[ Show hidden characters]({{ revealButtonHref }})
Resolve #4918, fix #5235. The important bits that I gathered from the discussion were:
- DRF should internally encode/decode only strict JSON, since other modules (eg, postgres's
JSONField
) may not be compatible with the extended float values (Infinity
,NaN
). Incompatible values should raise an exception. - Users may still want to render/parse extended JSON.
This PR does the following:
- Adds an internal
rest_framework.utils.json
module that defaults to strict JSON encoding/decoding. - All imports have been changed to
rest_framework.utils.json
, so they obey the stricter behavior. - Adds flake8-tidy-imports, which allows us direct users to import the json wrapper module.
- Adds
settings.STRICT_JSON
, which controls the strictness ofJSONParser
&JSONRenderer
. This defaults toTrue
, but users can revert to the old extended behavior by setting this toFalse
Ryan P Kilby added 4 commits
STRICT_JSON controls the renderer & parser behavior on whether or not to accept non-standard float values (NaN, Infinity).
Ryan P Kilby added 2 commits
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Worth a docstring here to highlight why we have this module.
Looks great. Deferring to 3.7.0.
carltongibson pushed a commit that referenced this pull request
Set version number for 3.7.0 release
Rename release notes section
Moved issue links to top for easier access. (Can move back later)
Strict JSON handling
Add release note for #5250
Add release notes for #5170
Add release notes for #5443
Add release notes for #5448
Add release notes for #5452
Add release not for #5342
Add release notes for 5454
Remove Django 1.8 & 1.9 from README and setup.py
- Release notes for merged 3.6.5 milestone tickets
Tickets migrated to 3.7.0 milestone.
Add release notes for #5469
Add release notes from AM 2ndOct
Add final changes to the release notes.
Add date and milestone link
Move issue links back to bottom.
Update translations from transifex
Begin releae anouncement
Add release note for #5482
3.7 release announcement & related docs.