From e99b319682fe984074e32f52354dbec23ded4d0a Mon Sep 17 00:00:00 2001 From: Harjoth Khara Date: Thu, 18 Jun 2026 09:55:06 -0700 Subject: [PATCH] gh-146353: Document `PyBytesWriter_GetData` pointer validity (GH-151418) --- Doc/c-api/bytes.rst | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Doc/c-api/bytes.rst b/Doc/c-api/bytes.rst index f56bcd6333a3..fa77d3d38ff8 100644 --- a/Doc/c-api/bytes.rst +++ b/Doc/c-api/bytes.rst @@ -384,14 +384,18 @@ Getters Get the writer size. + The function does not invalidate pointers returned by + :c:func:`PyBytesWriter_GetData`. + The function cannot fail. .. c:function:: void* PyBytesWriter_GetData(PyBytesWriter *writer) Get the writer data: start of the internal buffer. - The pointer is valid until :c:func:`PyBytesWriter_Finish` or - :c:func:`PyBytesWriter_Discard` is called on *writer*. + The pointer remains valid until a :c:type:`PyBytesWriter` function other + than :c:func:`PyBytesWriter_GetData` or :c:func:`PyBytesWriter_GetSize` is + called on *writer*. The function cannot fail. -- 2.47.3