8000 gh-119182: Add PyUnicodeWriter C API by vstinner · Pull Request #119184 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-119182: Add PyUnicodeWriter C API #119184

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 15 commits into from
Jun 17, 2024
Prev Previous commit
Next Next commit
Apply suggestions from code review
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
  • Loading branch information
vstinner and erlend-aasland authored Jun 10, 2024
commit e3e15f0d701a95d256ff2376e0adab497e1064e5
5 changes: 2 additions & 3 deletions Objects/unicodeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -13149,8 +13149,7 @@ PyUnicodeWriter_Create(Py_ssize_t length)
const size_t size = sizeof(_PyUnicodeWriter);
PyUnicodeWriter *pub_writer = (PyUnicodeWriter *)PyMem_Malloc(size);
if (pub_writer == NULL) {
PyErr_NoMemory();
return NULL;
return PyErr_NoMemory();
}
_PyUnicodeWriter *writer = (_PyUnicodeWriter *)pub_writer;

Expand Down Expand Up @@ -13481,7 +13480,7 @@ PyUnicodeWriter_WriteUTF8(PyUnicodeWriter *writer,
const char *str,
Py_ssize_t size)
{
if (size == -1) {
if (size < 0) {
size = strlen(str);
}
return unicode_decode_utf8_writer((_PyUnicodeWriter*)writer, str, size,
Expand Down
0