Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
Closed
Description
Bug report
When you try to serialize aNaN,inf or-inf withjson.dumps(..., allow_nan=False), the error messages are inconsistent, depending on whether you use theindent argument or not.
>>>json.dumps(float('nan'),allow_nan=False)ValueError:OutofrangefloatvaluesarenotJSONcompliant>>>json.dumps(float('nan'),allow_nan=False,indent=4)ValueError:OutofrangefloatvaluesarenotJSONcompliant:nan
That is because if you don't useindent, the encoding is done in C codehere,
but if you useindent, the encoding is done in pure Python codehere, and the error messages are different between the two.
Your environment
- CPython versions tested on: 3.11.0
- Operating system and architecture: MacOS 12.6, Apple Silicon
Linked PRs
Metadata
Metadata
Assignees
Projects
Status
Done