Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Inconsistent JSON serialization error messages #99925

Closed
Labels
type-bugAn unexpected behavior, bug, or error
@fnesveda

Description

@fnesveda

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

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or error

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp