Skip to content

Commit 5c188f5

Browse files
committed
Fix assert
1 parent 7bb7654 commit 5c188f5

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

Modules/_io/textio.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1587,7 +1587,7 @@ _textiowrapper_prepend(textio *self, PyObject *unwritten)
15871587

15881588
if (self->pending_bytes == NULL) {
15891589
self->pending_bytes = unwritten;
1590-
assert(self->pending_bytes == 0);
1590+
assert(self->pending_bytes_count == 0);
15911591
self->pending_bytes_count += PyBytes_GET_SIZE(unwritten);
15921592
}
15931593
else if (!PyList_CheckExact(self->pending_bytes)) {
@@ -1901,12 +1901,11 @@ _io_TextIOWrapper_write_impl(textio *self, PyObject *text)
19011901
// Flush the buffer before adding b to the buffer if b is not small.
19021902
// https://github.com/python/cpython/issues/87426
19031903
if (bytes_len >= self->chunk_size) {
1904-
/* writeflush works to ensure all data written.
1904+
/* writeflush ensures one pending_bytes is written.
19051905
19061906
Additional data may be written to the TextIO when the lock is
1907-
released while calling buffer.write (and show up in
1908-
pending_bytes). When that happens, flush again to avoid copying
1909-
the current bytes. */
1907+
released while calling buffer.write (and show up in pending_bytes).
1908+
When that happens, flush again to avoid copying the current bytes. */
19101909
while (self->pending_bytes != NULL) {
19111910
if (_textiowrapper_writeflush(self) < 0) {
19121911
Py_DECREF(b);

0 commit comments

Comments
 (0)