]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-148241: Fix json serialization for str subclasses (#148249)
authorVictor Stinner <vstinner@python.org>
Thu, 9 Apr 2026 11:50:44 +0000 (13:50 +0200)
committerGitHub <noreply@github.com>
Thu, 9 Apr 2026 11:50:44 +0000 (13:50 +0200)
commitb7e1d51e6b0764dd51e97c2b539e9633028afb2d
tree0e9a049698bbeebed01876641cfa263ae6d3ea03
parent8000a9de3c0b22f8202898a424c1008e13bd16ce
gh-148241: Fix json serialization for str subclasses (#148249)

Fix json serialization: no longer call str(obj) on str subclasses.

Replace PyUnicodeWriter_WriteStr() with PyUnicodeWriter_WriteASCII()
and private _PyUnicodeWriter_WriteStr().
Lib/test/test_json/test_dump.py
Lib/test/test_json/test_encode_basestring_ascii.py
Lib/test/test_json/test_enum.py
Misc/NEWS.d/next/Library/2026-04-08-14-19-17.gh-issue-148241.fO_QT4.rst [new file with mode: 0644]
Modules/_json.c