Skip to content

Commit 1364c3b

Browse files
committed
Fix substring length argument
1 parent 4173474 commit 1364c3b

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

Modules/_io/textio.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1715,7 +1715,7 @@ _textiowrapper_writeflush(textio *self)
17151715
if (bytes_to_write) {
17161716
pending = PyBytes_FromStringAndSize(
17171717
PyBytes_AS_STRING(b) + err->written,
1718-
self->pending_bytes_count);
1718+
bytes_to_write);
17191719
if (pending) {
17201720
/* _textiowrapper can raise an exception if it fails to
17211721
allocate a list, that just adds to active error
@@ -1803,15 +1803,14 @@ _textiowrapper_writeflush(textio *self)
18031803
/* Make a new PyBytes to keep type for next call to write. */
18041804
pending = PyBytes_FromStringAndSize(
18051805
PyBytes_AS_STRING(b) + size,
1806-
self->pending_bytes_count);
1806+
bytes_to_write);
18071807
Py_DECREF(b);
18081808
b = pending;
18091809
pending = NULL;
18101810
}
18111811

18121812
/* All data owned by this function is written. Other bytes could have shown
18131813
up while running. */
1814-
assert(self->pending_bytes_count >= 0);
18151814
Py_DECREF(b);
18161815
return 0;
18171816
}

0 commit comments

Comments
 (0)