Skip to content

Commit d824240

Browse files
authored
Doc: fix PyBytesWriter sample code (#160756)
1 parent dbf9776 commit d824240

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
@@ -494,7 +494,7 @@ Variant using a pointer to compute the final size::
494494
495495
char *str = PyBytesWriter_GetData(writer);
496496
memcpy(str, "abc", 3);
497-
str += 1;
497+
str += 3;
498498
return PyBytesWriter_FinishWithPointer(writer, str);
499499
}
500500
@@ -543,7 +543,7 @@ Update ``_PyBytes_Resize()`` code
543543
544544
Example of code using the soft deprecated ``_PyBytes_Resize()`` API::
545545
546-
void create_string(Py_ssize_t size)
546+
PyObject* create_string(Py_ssize_t size)
547547
{
548548
PyObject *bytes = PyBytes_FromStringAndSize(NULL, size);
549549
if (bytes == NULL) {
@@ -561,7 +561,7 @@ Example of code using the soft deprecated ``_PyBytes_Resize()`` API::
561561
562562
It can now be updated to::
563563
564-
void create_string(Py_ssize_t size)
564+
PyObject* create_string(Py_ssize_t size)
565565
{
566566
PyBytesWriter *writer = PyBytesWriter_Create(size);
567567
if (writer == NULL) {

0 commit comments

Comments
 (0)