https://github.com/python/cpython/commit/d8242407a52fe55520ecd84bd088505291e6992f
commit: d8242407a52fe55520ecd84bd088505291e6992f
branch: main
author: Inada Naoki <[email protected]>
committer: methane <[email protected]>
date: 2026-10-28T11:45:16+09:00
summary:
Doc: fix PyBytesWriter sample code (#160756)
files:
M Doc/c-api/bytes.rst
diff --git a/Doc/c-api/bytes.rst b/Doc/c-api/bytes.rst
index 1fcdf2ba5d983f..2d17a75edf811e 100644
--- a/Doc/c-api/bytes.rst
+++ b/Doc/c-api/bytes.rst
@@ -494,7 +494,7 @@ Variant using a pointer to compute the final size::
char *str = PyBytesWriter_GetData(writer);
memcpy(str, "abc", 3);
- str += 1;
+ str += 3;
return PyBytesWriter_FinishWithPointer(writer, str);
}
@@ -543,7 +543,7 @@ Update ``_PyBytes_Resize()`` code
Example of code using the soft deprecated ``_PyBytes_Resize()`` API::
- void create_string(Py_ssize_t size)
+ PyObject* create_string(Py_ssize_t size)
{
PyObject *bytes = PyBytes_FromStringAndSize(NULL, size);
if (bytes == NULL) {
@@ -561,7 +561,7 @@ Example of code using the soft deprecated
``_PyBytes_Resize()`` API::
It can now be updated to::
- void create_string(Py_ssize_t size)
+ PyObject* create_string(Py_ssize_t size)
{
PyBytesWriter *writer = PyBytesWriter_Create(size);
if (writer == NULL) {
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]