summaryrefslogtreecommitdiffstats
path: root/Lib/_pyio.py
diff options
context:
space:
mode:
authorCody Maloney <cmaloney@users.noreply.github.com>2025-03-07 01:18:22 (GMT)
committerGitHub <noreply@github.com>2025-03-07 01:18:22 (GMT)
commit886a4d74ee7b19d027fae1ba4579a99a805878a2 (patch)
tree2d0f2971350faa18313a1f802ee4102212bc1fbe /Lib/_pyio.py
parenta385add4015c431534e29cd3cfcc5763a62ef048 (diff)
downloadcpython-886a4d74ee7b19d027fae1ba4579a99a805878a2.zip
cpython-886a4d74ee7b19d027fae1ba4579a99a805878a2.tar.gz
cpython-886a4d74ee7b19d027fae1ba4579a99a805878a2.tar.bz2
gh-129011: Update comments in FileIO to match current code (#129012)
Diffstat (limited to 'Lib/_pyio.py')
-rw-r--r--Lib/_pyio.py17
1 files changed, 14 insertions, 3 deletions
diff --git a/Lib/_pyio.py b/Lib/_pyio.py
index e915e5b..99d6f79 100644
--- a/Lib/_pyio.py
+++ b/Lib/_pyio.py
@@ -1645,7 +1645,13 @@ class FileIO(RawIOBase):
def read(self, size=None):
"""Read at most size bytes, returned as bytes.
- Only makes one system call, so less data may be returned than requested
+ If size is less than 0, read all bytes in the file making
+ multiple read calls. See ``FileIO.readall``.
+
+ Attempts to make only one system call, retrying only per
+ PEP 475 (EINTR). This means less data may be returned than
+ requested.
+
In non-blocking mode, returns None if no data is available.
Return an empty bytes object at EOF.
"""
@@ -1661,8 +1667,13 @@ class FileIO(RawIOBase):
def readall(self):
"""Read all data from the file, returned as bytes.
- In non-blocking mode, returns as much as is immediately available,
- or None if no data is available. Return an empty bytes object at EOF.
+ Reads until either there is an error or read() returns size 0
+ (indicates EOF). If the file is already at EOF, returns an
+ empty bytes object.
+
+ In non-blocking mode, returns as much data as could be read
+ before EAGAIN. If no data is available (EAGAIN is returned
+ before bytes are read) returns None.
"""
self._checkClosed()
self._checkReadable()