Skip to content

Commit 2336d0e

Browse files
committed
Respond to review from Bénédikt
1 parent ffd48e4 commit 2336d0e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Include/internal/pycore_blocks_output_buffer.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ extern "C" {
4545
#endif
4646

4747
typedef struct {
48-
// List of bytes objects
48+
// Bytes writer managing output buffer
4949
PyBytesWriter *writer;
5050
// Number of whole allocated size
5151
Py_ssize_t allocated;
@@ -154,7 +154,7 @@ _BlocksOutputBuffer_InitWithSize(_BlocksOutputBuffer *buffer,
154154

155155
buffer->writer = PyBytesWriter_Create(init_size);
156156
if (buffer->writer == NULL) {
157-
PyErr_SetString(PyExc_MemoryError, unable_allocate_msg);
157+
// PyBytesWriter_Create already sets an exception when out of memory.
158158
return -1;
159159
}
160160

@@ -244,6 +244,7 @@ static inline PyObject *
244244
_BlocksOutputBuffer_Finish(_BlocksOutputBuffer *buffer,
245245
const Py_ssize_t avail_out)
246246
{
247+
assert(buffer->writer != NULL);
247248
return PyBytesWriter_FinishWithSize(buffer->writer,
248249
buffer->allocated - avail_out);
249250
}
@@ -253,6 +254,7 @@ static inline void
253254
_BlocksOutputBuffer_OnError(_BlocksOutputBuffer *buffer)
254255
{
255256
PyBytesWriter_Discard(buffer->writer);
257+
buffer->writer = NULL;
256258
}
257259

258260
#ifdef __cplusplus

0 commit comments

Comments
 (0)