Skip to content

Commit f95a23c

Browse files
Doc: fix PyBytesWriter sample code (GH-160756)
(cherry picked from commit d824240) Co-authored-by: Inada Naoki <songofacandy@gmail.com>
1 parent 634c1d2 commit f95a23c

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

‎Doc/c-api/bytes.rst‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ Variant using a pointer to compute the final size::
488488
489489
char *str = PyBytesWriter_GetData(writer);
490490
memcpy(str, "abc", 3);
491-
str += 1;
491+
str += 3;
492492
return PyBytesWriter_FinishWithPointer(writer, str);
493493
}
494494
@@ -537,7 +537,7 @@ Update ``_PyBytes_Resize()`` code
537537
538538
Example of code using the soft deprecated ``_PyBytes_Resize()`` API::
539539
540-
void create_string(Py_ssize_t size)
540+
PyObject* create_string(Py_ssize_t size)
541541
{
542542
PyObject *bytes = PyBytes_FromStringAndSize(NULL, size);
543543
if (bytes == NULL) {
@@ -555,7 +555,7 @@ Example of code using the soft deprecated ``_PyBytes_Resize()`` API::
555555
556556
It can now be updated to::
557557
558-
void create_string(Py_ssize_t size)
558+
PyObject* create_string(Py_ssize_t size)
559559
{
560560
PyBytesWriter *writer = PyBytesWriter_Create(size);
561561
if (writer == NULL) {

0 commit comments

Comments
 (0)