8000 gh-133968: Use private unicode writer for json by nineteendo · Pull Request #133832 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-133968: Use private unicode writer for json #133832

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
May 31, 2025
Prev Previous commit
Merge branch 'main' into json-private-unicode-writer
  • Loading branch information
nineteendo committed May 30, 2025
commit 566637c24ae1eb92345ee175b6a71096602fd973
10 changes: 5 additions & 5 deletions Modules/_json.c
Original file line number Diff line number Diff line change
Expand Up @@ -1470,13 +1470,13 @@ encoder_listencode_obj(PyEncoderObject *s, PyUnicodeWriter *writer,
int rv;

if (obj == Py_None) {
return _PyUnicodeWriter_WriteASCIIString((_PyUnicodeWriter *)writer, "null", 4);
return PyUnicodeWriter_WriteASCII(writer, "null", 4);
}
else if (obj == Py_True) {
return _PyUnicodeWriter_WriteASCIIString((_PyUnicodeWriter *)writer, "true", 4);
return PyUnicodeWriter_WriteASCII(writer, "true", 4);
}
else if (obj == Py_False) {
return _PyUnicodeWriter_WriteASCIIString((_PyUnicodeWriter *)writer, "false", 5);
return PyUnicodeWriter_WriteASCII(writer, "false", 5);
}
else if (PyUnicode_Check(obj)) {
PyObject *encoded = encoder_encode_string(s, obj);
Expand Down Expand Up @@ -1643,7 +1643,7 @@ encoder_listencode_dict(PyEncoderObject *s, PyUnicodeWriter *writer,

if (PyDict_GET_SIZE(dct) == 0) {
/* Fast path */
return _PyUnicodeWriter_WriteASCIIString((_PyUnicodeWriter *)writer, "{}", 2);
return PyUnicodeWriter_WriteASCII(writer, "{}", 2);
}

if (s->markers != Py_None) {
Expand Down Expand Up @@ -1747,7 +1747,7 @@ encoder_listencode_list(PyEncoderObject *s, PyUnicodeWriter *writer,
return -1;
if (PySequence_Fast_GET_SIZE(s_fast) == 0) {
Py_DECREF(s_fast);
return _PyUnicodeWriter_WriteASCIIString((_PyUnicodeWriter *)writer, "[]", 2);
return PyUnicodeWriter_WriteASCII(writer, "[]", 2);
}

if (s->markers != Py_None) {
Expand Down
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.
0