Inada Naoki <[email protected]> added the comment:
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.
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue43260>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com