json skipkeys=True results in invalid json with a trailing comma on pypy3

Create issue
Issue #3052 resolved
Glyph created an issue

import json
print(json.dumps({
    "hello": "what",
    b"world": "what",
}, skipkeys=True))

$ python3 j3.py
{"hello": "what"}
$ pypy3 j3.py
{"hello": "what", }

Comments (6)

  1. Armin Rigo

    It's not a trailing comma, it's more that the non-string keys give zero-length outputs that are still comma-delimited, instead of being fully ignored:

    >>>> print(json.dumps({
        b"w": 1, b"x": 2, b"y": 3
        }, skipkeys=True))
    {, , }
    
  2. Log in to comment