Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 45a4372

Browse files
committed
Merged revisions 76900 via svnmerge from
svn+ssh://[email protected]/python/branches/py3k ................ r76900 | antoine.pitrou | 2009-12-19 22:08:31 +0100 (sam., 19 déc. 2009) | 13 lines Merged revisions 76896,76898 via svnmerge from svn+ssh://[email protected]/python/trunk ........ r76896 | antoine.pitrou | 2009-12-19 22:01:10 +0100 (sam., 19 déc. 2009) | 3 lines Issue #7545: improve documentation of the `buffering` argument in io.open(). ........ r76898 | antoine.pitrou | 2009-12-19 22:06:36 +0100 (sam., 19 déc. 2009) | 3 lines Remove superfetatory paragraph (left there by mistake). ........ ................
1 parent b1a1810 commit 45a4372

3 files changed

Lines changed: 42 additions & 12 deletions

File tree

Doc/library/io.rst

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,20 @@ Module Interface
9696
strings, the bytes having been first decoded using a platform-dependent
9797
encoding or using the specified *encoding* if given.
9898

99-
*buffering* is an optional integer used to set the buffering policy. By
100-
default full buffering is on. Pass 0 to switch buffering off (only allowed
101-
in binary mode), 1 to set line buffering, and an integer > 1 to indicate the
102-
size of the buffer.
99+
*buffering* is an optional integer used to set the buffering policy.
100+
Pass 0 to switch buffering off (only allowed in binary mode), 1 to select
101+
line buffering (only usable in text mode), and an integer > 1 to indicate
102+
the size of a fixed-size chunk buffer. When no *buffering* argument is
103+
given, the default buffering policy works as follows:
104+
105+
* Binary files are buffered in fixed-size chunks; the size of the buffer
106+
is chosen using a heuristic trying to determine the underlying device's
107+
"block size" and falling back on :attr:`DEFAULT_BUFFER_SIZE`.
108+
On many systems, the buffer will typically be 4096 or 8192 bytes long.
109+
110+
* "Interactive" text files (files for which :meth:`isatty` returns True)
111+
use line buffering. Other text files use the policy described above
112+
for binary files.
103113

104114
*encoding* is the name of the encoding used to decode or encode the file.
105115
This should only be used in text mode. The default encoding is platform

Lib/_pyio.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,20 @@ def open(file: (str, bytes), mode: str = "r", buffering: int = None,
8282
returned as strings, the bytes having been first decoded using a
8383
platform-dependent encoding or using the specified encoding if given.
8484
85-
buffering is an optional integer used to set the buffering policy. By
86-
default full buffering is on. Pass 0 to switch buffering off (only
87-
allowed in binary mode), 1 to set line buffering, and an integer > 1
88-
for full buffering.
85+
buffering is an optional integer used to set the buffering policy.
86+
Pass 0 to switch buffering off (only allowed in binary mode), 1 to select
87+
line buffering (only usable in text mode), and an integer > 1 to indicate
88+
the size of a fixed-size chunk buffer. When no buffering argument is
89+
given, the default buffering policy works as follows:
90+
91+
* Binary files are buffered in fixed-size chunks; the size of the buffer
92+
is chosen using a heuristic trying to determine the underlying device's
93+
"block size" and falling back on `io.DEFAULT_BUFFER_SIZE`.
94+
On many systems, the buffer will typically be 4096 or 8192 bytes long.
95+
96+
* "Interactive" text files (files for which isatty() returns True)
97+
use line buffering. Other text files use the policy described above
98+
for binary files.
8999
90100
encoding is the name of the encoding used to decode or encode the
91101
file. This should only be used in text mode. The default encoding is

Modules/_io/_iomodule.c

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,10 +219,20 @@ PyDoc_STRVAR(open_doc,
219219
"returned as strings, the bytes having been first decoded using a\n"
220220
"platform-dependent encoding or using the specified encoding if given.\n"
221221
"\n"
222-
"buffering is an optional integer used to set the buffering policy. By\n"
223-
"default full buffering is on. Pass 0 to switch buffering off (only\n"
224-
"allowed in binary mode), 1 to set line buffering, and an integer > 1\n"
225-
"for full buffering.\n"
222+
"buffering is an optional integer used to set the buffering policy.\n"
223+
"Pass 0 to switch buffering off (only allowed in binary mode), 1 to select\n"
224+
"line buffering (only usable in text mode), and an integer > 1 to indicate\n"
225+
"the size of a fixed-size chunk buffer. When no buffering argument is\n"
226+
"given, the default buffering policy works as follows:\n"
227+
"\n"
228+
"* Binary files are buffered in fixed-size chunks; the size of the buffer\n"
229+
" is chosen using a heuristic trying to determine the underlying device's\n"
230+
" \"block size\" and falling back on `io.DEFAULT_BUFFER_SIZE`.\n"
231+
" On many systems, the buffer will typically be 4096 or 8192 bytes long.\n"
232+
"\n"
233+
"* \"Interactive\" text files (files for which isatty() returns True)\n"
234+
" use line buffering. Other text files use the policy described above\n"
235+
" for binary files.\n"
226236
"\n"
227237
"encoding is the name of the encoding used to decode or encode the\n"
228238
"file. This should only be used in text mode. The default encoding is\n"

0 commit comments

Comments
 (0)