Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-129011: Update comments in FileIO to match current code#129012

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
hauntsaninja merged 11 commits intopython:mainfromcmaloney:fileio_comments
Mar 7, 2025
Merged
Show file tree
Hide file tree
Changes fromall 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
17 changes: 14 additions & 3 deletionsLib/_pyio.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1645,7 +1645,13 @@ def _checkWritable(self, msg=None):
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.
"""
Expand All@@ -1661,8 +1667,13 @@ def read(self, size=None):
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()
Expand Down
20 changes: 14 additions & 6 deletionsModules/_io/clinic/fileio.c.h
View file
Open in desktop

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

22 changes: 15 additions & 7 deletionsModules/_io/fileio.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -727,13 +727,16 @@ _io.FileIO.readall

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.
[clinic start generated code]*/

static PyObject *
_io_FileIO_readall_impl(fileio *self)
/*[clinic end generated code: output=faa0292b213b4022 input=dbdc137f55602834]*/
/*[clinic end generated code: output=faa0292b213b4022 input=1e19849857f5d0a1]*/
{
Py_off_t pos, end;
PyObject *result;
Expand DownExpand Up@@ -848,14 +851,19 @@ _io.FileIO.read

Read at most size bytes, returned as bytes.

Only makes one system call, so 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.
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.
[clinic start generated code]*/

static PyObject *
_io_FileIO_read_impl(fileio *self, PyTypeObject *cls, Py_ssize_t size)
/*[clinic end generated code: output=bbd749c7c224143e input=f613d2057e4a1918]*/
/*[clinic end generated code: output=bbd749c7c224143e input=cf21fddef7d38ab6]*/
{
char *ptr;
Py_ssize_t n;
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp