File tree Expand file tree Collapse file tree 2 files changed +9
-20
lines changed Expand file tree Collapse file tree 2 files changed +9
-20
lines changed Original file line number Diff line number Diff line change @@ -1674,31 +1674,22 @@ def readall(self):
16741674 except OSError :
16751675 pass
16761676
1677- result = bytearray (bufsize )
1678- bytes_read = 0
1677+ result = bytearray ()
16791678 while True :
1680- if bytes_read >= bufsize :
1681- # Parallels _io/fileio.c new_buffersize
1682- if bufsize > 65536 :
1683- addend = bufsize >> 3
1684- else :
1685- addend = bufsize + 256
1686- if addend < DEFAULT_BUFFER_SIZE :
1687- addend = DEFAULT_BUFFER_SIZE
1688- bufsize += addend
1689- result [bytes_read :bufsize ] = b'\0 '
1690- assert bufsize - bytes_read > 0 , "Should always try and read at least one byte"
1679+ if len (result ) >= bufsize :
1680+ bufsize = len (result )
1681+ bufsize += max (bufsize , DEFAULT_BUFFER_SIZE )
1682+ n = bufsize - len (result )
16911683 try :
1692- n = os .readinto (self ._fd , memoryview ( result )[ bytes_read :] )
1684+ chunk = os .read (self ._fd , n )
16931685 except BlockingIOError :
1694- if bytes_read > 0 :
1686+ if result :
16951687 break
16961688 return None
1697- if n == 0 : # reached the end of the file
1689+ if not chunk : # reached the end of the file
16981690 break
1699- bytes_read += n
1691+ result += chunk
17001692
1701- del result [bytes_read :]
17021693 return bytes (result )
17031694
17041695 def readinto (self , buffer ):
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments