This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author methane
Recipients Ramin Farajpour Cami, eryksun, methane, paul.moore, steve.dower, tim.golden, zach.ware
Date 2021-02-20.04:53:52
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1613796832.36.0.750242462837.issue43260@roundup.psfhosted.org>
In-reply-to
Content
In your code, huge data passed to .write(huge) may be remained in the internal buffer.

```
[NEW PRE-FLUSH]

    else if ((self->pending_bytes_count + bytes_len) > self->chunk_size) {
        if (_textiowrapper_writeflush(self) < 0) {
            Py_DECREF(b);
            return NULL;
        }
        self->pending_bytes = b;
    }
(snip)
    self->pending_bytes_count += bytes_len;
    if (self->pending_bytes_count > self->chunk_size || needflush ||
        text_needflush) {
        if (_textiowrapper_writeflush(self) < 0)
            return NULL;
    }
```

In my opinion, when .write(huge) fails with MemoryError, TextIOWrapper must not keep the `huge` in the internal buffer.

See my PR-24592.
History
Date User Action Args
2021-02-20 04:53:52methanesetrecipients: + methane, paul.moore, tim.golden, zach.ware, eryksun, steve.dower, Ramin Farajpour Cami
2021-02-20 04:53:52methanesetmessageid: <1613796832.36.0.750242462837.issue43260@roundup.psfhosted.org>
2021-02-20 04:53:52methanelinkissue43260 messages
2021-02-20 04:53:52methanecreate