Skip to content

Commit 12ecdf7

Browse files
committed
implement buffer getter
1 parent 828618f commit 12ecdf7

2 files changed

Lines changed: 41 additions & 3 deletions

File tree

Modules/_io/clinic/textio.c.h

Lines changed: 26 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/_io/textio.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1639,7 +1639,7 @@ _io_TextIOWrapper_detach_impl(textio *self)
16391639
if (buffer == NULL) {
16401640
return NULL;
16411641
}
1642-
FT_ATOMIC_STORE_PTR_RELAXED(self->buffer, NULL);
1642+
self->buffer = NULL;
16431643
self->detached = 1;
16441644
return buffer;
16451645
}
@@ -3424,6 +3424,19 @@ _io_TextIOWrapper__CHUNK_SIZE_set_impl(textio *self, PyObject *value)
34243424
return 0;
34253425
}
34263426

3427+
/*[clinic input]
3428+
@critical_section
3429+
@getter
3430+
_io.TextIOWrapper.buffer
3431+
[clinic start generated code]*/
3432+
3433+
static PyObject *
3434+
_io_TextIOWrapper_buffer_get_impl(textio *self)
3435+
/*[clinic end generated code: output=d265a34555aa5d4b input=5951cfa148f7350a]*/
3436+
{
3437+
return Py_NewRef(self->buffer);
3438+
}
3439+
34273440
static PyMethodDef incrementalnewlinedecoder_methods[] = {
34283441
_IO_INCREMENTALNEWLINEDECODER_DECODE_METHODDEF
34293442
_IO_INCREMENTALNEWLINEDECODER_GETSTATE_METHODDEF
@@ -3482,7 +3495,6 @@ static PyMethodDef textiowrapper_methods[] = {
34823495

34833496
static PyMemberDef textiowrapper_members[] = {
34843497
{"encoding", _Py_T_OBJECT, offsetof(textio, encoding), Py_READONLY},
3485-
{"buffer", _Py_T_OBJECT, offsetof(textio, buffer), Py_READONLY},
34863498
{"line_buffering", Py_T_BOOL, offsetof(textio, line_buffering), Py_READONLY},
34873499
{"write_through", Py_T_BOOL, offsetof(textio, write_through), Py_READONLY},
34883500
{"_finalizing", Py_T_BOOL, offsetof(textio, finalizing), 0},
@@ -3497,6 +3509,7 @@ static PyGetSetDef textiowrapper_getset[] = {
34973509
_IO_TEXTIOWRAPPER_NEWLINES_GETSETDEF
34983510
_IO_TEXTIOWRAPPER_ERRORS_GETSETDEF
34993511
_IO_TEXTIOWRAPPER__CHUNK_SIZE_GETSETDEF
3512+
_IO_TEXTIOWRAPPER_BUFFER_GETSETDEF
35003513
{NULL}
35013514
};
35023515

0 commit comments

Comments
 (0)