Possibly Wrong json encoding and decoding of surrogated pairs

Open
#94,527 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
python
Domain
data

Research direction

Start by reproducing the reported round-trip with json.dumps and json.loads, using the surrogate pair shown in the issue and the listed Python versions. Trace how the JSON encoder and decoder handle the pair; done means the assertion passes without changing unrelated JSON behavior.

Written by the indexing model from the issue text.

Description

stdlib type-bug

Bug report
Hi, I found a small non-urgent bug so feel free to ignore it.

import json
assert '\udb0a\udfdf' == json.loads(json.dumps('\udb0a\udfdf'))

results in:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AssertionError

Your environment
I managed to reproduce it in your maylinux2010 docker for the versions 3.6, 3.7, 3.8, 3.9, 3.10.

sudo docker run -it manylinux2010
Dominant language
Python
Stars
77.2k
Forks
36k
Avg merge
1d 9h
Merged PRs (30d)
558

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from python/cpython

All issues in python/cpython

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.