Skip to content

Commit c55d10e

Browse files
committed
Add _pyiio +1 comment to fileio for better clarity
1 parent d18a82d commit c55d10e

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

Modules/_io/fileio.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -747,14 +747,16 @@ _io_FileIO_readall_impl(fileio *self)
747747
bufsize = SMALLCHUNK;
748748
}
749749
else {
750-
/* This is probably a real file, so we try to allocate a
751-
buffer one byte larger than the rest of the file. If the
752-
calculation is right then we should get EOF without having
753-
to enlarge the buffer. */
750+
/* This is probably a real file. */
754751
if (end > _PY_READ_MAX - 1) {
755752
bufsize = _PY_READ_MAX;
756753
}
757754
else {
755+
/* In order to detect end of file, need a read() of at
756+
least 1 byte which returns size 0. Oversize the buffer
757+
by 1 byte so the I/O can be completed with two read()
758+
calls (one for all data, one for EOF) without needing
759+
to resize the buffer. */
758760
bufsize = (size_t)end + 1;
759761
}
760762

0 commit comments

Comments
 (0)