GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Inconsistent JSON serialization error messages · Issue #99925 · python/cpython

Inconsistent JSON serialization error messages #99925

New issue
Copy link
New issue
Copy link
Closed
#99926
Closed
Inconsistent JSON serialization error messages#99925
#99926
Copy link
Labels
type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@fnesveda
fnesveda
opened on Dec 1, 2022
Issue body actions

Bug report

When you try to serialize a NaN, inf or -inf with json.dumps(..., allow_nan=False), the error messages are inconsistent, depending on whether you use the indent argument or not.

>>> json.dumps(float('nan'), allow_nan=False)
ValueError: Out of range float values are not JSON compliant

>>> json.dumps(float('nan'), allow_nan=False, indent=4)
ValueError: Out of range float values are not JSON compliant: nan

That is because if you don't use indent, the encoding is done in C code here,
but if you use indent, the encoding is done in pure Python code here, 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

  • gh-99925: Fix inconsistency in json.dumps() error messages #99926

Activity

  1. fnesveda
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on Dec 1, 2022
  2. fnesveda
    added a commit that references this issue on Dec 1, 2022

    pythongh-99925: Fix inconsistency in `json.dumps()` error messages

    94f9f59
  3. serhiy-storchaka
    added this to JSON issueson Dec 15, 2022
  4. serhiy-storchaka
    closed this as completedin #99926on Dec 20, 2022
  5. serhiy-storchaka
    moved this to Done in JSON issueson Dec 20, 2022
  6. serhiy-storchaka
    added a commit that references this issue on Dec 20, 2022

    gh-99925: Fix inconsistency in `json.dumps()` error messages (GH-99926)

    d98ca81
  7. serhiy-storchaka commented on Dec 20, 2022

    @serhiy-storchaka
    serhiy-storchaka
    on Dec 20, 2022
    Member
    More actions

    Thank you for your contribution, @fnesveda.

  8. jonburdo
    added a commit that references this issue on Dec 20, 2022

    pythongh-99925: Fix inconsistency in `json.dumps()` error messages (p…

    db820a2
  9. iritkatriel
    added a commit that references this issue on Dec 28, 2022

    Merged main into regmachine branch (#50)

    fdc73cb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

    Projects

    • JSON issues
      Status
      Done
      Show more project fields

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.