Skip to content

Commit d6b8415

Browse files
committed
[GR-29471] Grow buffer size for unbounded reads.
PullRequest: graalpython/1623
2 parents 29924ab + c5ec5a4 commit d6b8415

File tree

1 file changed

+2
-1
lines changed
  • graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io

1 file changed

+2
-1
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/FileIOBuiltins.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,8 @@ Object readall(VirtualFrame frame, PFileIO self,
496496
int bytesRead = 0;
497497
while (true) {
498498
if (bytesRead >= bufsize) {
499-
bufsize = Math.min(SMALLCHUNK, MAX_SIZE - bytesRead);
499+
// see CPython's function 'fileio.c: new_buffersize'
500+
bufsize = bytesRead + Math.max(SMALLCHUNK, bytesRead + 256);
500501
if (bufsize <= 0) {
501502
throw raise(OverflowError, UNBOUNDED_READ_RETURNED_MORE_BYTES);
502503
}

0 commit comments

Comments
 (0)