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

Appearance settings

gh-93600: Clarify the meaning of buffering=-1 in open() #93685

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 13 commits into
base: main
Choose a base branch
Loading
from
12 changes: 6 additions & 6 deletions 12 Doc/library/functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1181,12 +1181,12 @@ are always available. They are listed here in alphabetical order.
*buffering* is an optional integer used to set the buffering policy. Pass 0
to switch buffering off (only allowed in binary mode), 1 to select line
buffering (only usable in text mode), and an integer > 1 to indicate the size
eamanu marked this conversation as resolved.
Show resolved Hide resolved
in bytes of a fixed-size chunk buffer. Note that specifying a buffer size this
way applies for binary buffered I/O, but ``TextIOWrapper`` (i.e., files opened
with ``mode='r+'``) would have another buffering. To disable buffering in
``TextIOWrapper``, consider using the ``write_through`` flag for
:func:`io.TextIOWrapper.reconfigure`. When no *buffering* argument is
given, the default buffering policy works as follows:
in bytes of a fixed-size chunk buffer, or -1 to use the default buffer size.
eamanu marked this conversation as resolved.
Show resolved Hide resolved
Note that specifying a buffer size this way applies for binary buffered I/O,
but ``TextIOWrapper`` (i.e., files opened with ``mode='r+'``) would have
another buffering. To disable buffering in ``TextIOWrapper``, consider using
the ``write_through`` flag for :func:`io.TextIOWrapper.reconfigure`. When no
*buffering* argument is given, the default buffering policy works as follows:

* Binary files are buffered in fixed-size chunks; the size of the buffer is
chosen using a heuristic trying to determine the underlying device's "block
Expand Down
5 changes: 3 additions & 2 deletions 5 Lib/_pyio.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,9 @@ def open(file, mode="r", buffering=-1, encoding=None, errors=None,
buffering is an optional integer used to set the buffering policy.
Pass 0 to switch buffering off (only allowed in binary mode), 1 to select
line buffering (only usable in text mode), and an integer > 1 to indicate
eamanu marked this conversation as resolved.
Show resolved Hide resolved
the size of a fixed-size chunk buffer. When no buffering argument is
given, the default buffering policy works as follows:
the size of a fixed-size chunk buffer, or-1 to use the default buffer size.
eamanu marked this conversation as resolved.
Show resolved Hide resolved
When no buffering argument is given, the default buffering policy works as
follows:

* Binary files are buffered in fixed-size chunks; the size of the buffer
is chosen using a heuristic trying to determine the underlying device's
Expand Down
5 changes: 3 additions & 2 deletions 5 Modules/_io/_iomodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,9 @@ platform-dependent encoding or using the specified encoding if given.
buffering is an optional integer used to set the buffering policy.
Pass 0 to switch buffering off (only allowed in binary mode), 1 to select
line buffering (only usable in text mode), and an integer > 1 to indicate
eamanu marked this conversation as resolved.
Show resolved Hide resolved
the size of a fixed-size chunk buffer. When no buffering argument is
given, the default buffering policy works as follows:
the size of a fixed-size chunk buffer, or -1 to use the default buffer
size. When no buffering argument is given, the default buffering policy
eamanu marked this conversation as resolved.
Show resolved Hide resolved
works as follows:

* Binary files are buffered in fixed-size chunks; the size of the buffer
is chosen using a heuristic trying to determine the underlying device's
Expand Down
5 changes: 3 additions & 2 deletions 5 Modules/_io/clinic/_iomodule.c.h

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

Morty Proxy This is a proxified and sanitized view of the page, visit original site.