Skip to content

Commit 07e69a0

Browse files
committed
Address Benedikt's review
1 parent 8a2fcb6 commit 07e69a0

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

peps/pep-0782.rst

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,20 @@ Create, Finish, Discard
106106
Similar to :c:func:`PyBytesWriter_Finish`, but resize the writer
107107
using *buf* pointer before creating the :class:`bytes` object.
108108
109+
Pseudo-code::
110+
111+
Py_ssize_t size = (char*)buf - (char*)PyBytesWriter_GetData(writer);
112+
return PyBytesWriter_FinishWithSize(writer, size);
113+
114+
Set an exception and return ``NULL`` if *buf* pointer is invalid:
115+
outside the internal buffer bounds.
116+
109117
.. c:function:: void PyBytesWriter_Discard(PyBytesWriter *writer)
110118
111119
Discard a :c:type:`PyBytesWriter` created by :c:func:`PyBytesWriter_Create`.
112120
121+
Do nothing if *writer* is ``NULL``.
122+
113123
The writer instance is invalid after the call.
114124
115125
High-level API
@@ -155,6 +165,8 @@ Low-level API
155165
Resize the writer to *size* bytes. It can be used to enlarge or to
156166
shrink the writer.
157167
168+
Newly allocated bytes are left uninitialized.
169+
158170
On success, return ``0``.
159171
On error, set an exception and return ``-1``.
160172
@@ -164,6 +176,8 @@ Low-level API
164176
165177
Resize the writer by adding *grow* bytes to the current writer size.
166178
179+
Newly allocated bytes are left uninitialized.
180+
167181
On success, return ``0``.
168182
On error, set an exception and return ``-1``.
169183
@@ -174,6 +188,16 @@ Low-level API
174188
Similar to :c:func:`PyBytesWriter_Grow`, but update also the *buf*
175189
pointer.
176190
191+
On error, set an exception and return ``NULL``.
192+
193+
Pseudo-code::
194+
195+
Py_ssize_t pos = (char*)buf - (char*)PyBytesWriter_GetData(writer);
196+
if (PyBytesWriter_Grow(writer, size) < 0) {
197+
return NULL;
198+
}
199+
return (char*)PyBytesWriter_GetData(writer) + pos;
200+
177201
178202
Overallocation
179203
--------------

0 commit comments

Comments
 (0)