Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 9 additions & 18 deletions Lib/_pyio.py
Original file line number Diff line number Diff line change
Expand Up @@ -1674,31 +1674,22 @@ def readall(self):
except OSError:
pass

result = bytearray(bufsize)
bytes_read = 0
result = bytearray()
while True:
if bytes_read >= bufsize:
# Parallels _io/fileio.c new_buffersize
if bufsize > 65536:
addend = bufsize >> 3
else:
addend = bufsize + 256
if addend < DEFAULT_BUFFER_SIZE:
addend = DEFAULT_BUFFER_SIZE
bufsize += addend
result[bytes_read:bufsize] = b'\0'
assert bufsize - bytes_read > 0, "Should always try and read at least one byte"
if len(result) >= bufsize:
bufsize = len(result)
bufsize += max(bufsize, DEFAULT_BUFFER_SIZE)
n = bufsize - len(result)
try:
n = os.readinto(self._fd, memoryview(result)[bytes_read:])
chunk = os.read(self._fd, n)
except BlockingIOError:
if bytes_read > 0:
if result:
break
return None
if n == 0: # reached the end of the file
if not chunk: # reached the end of the file
break
bytes_read += n
result += chunk

del result[bytes_read:]
return bytes(result)

def readinto(self, buffer):
Expand Down

This file was deleted.

Loading