summaryrefslogtreecommitdiffstats
path: root/Modules/_io
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2009-12-19 21:01:10 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2009-12-19 21:01:10 (GMT)
commite812d29b52c597363d8d2c2615def653701a0efc (patch)
treeb2bfee34b41a6d46bc731d1e48b4c17b1380ff78 /Modules/_io
parentd86e9d7616dbc6e9c836803619294e07757ba091 (diff)
downloadcpython-e812d29b52c597363d8d2c2615def653701a0efc.zip
cpython-e812d29b52c597363d8d2c2615def653701a0efc.tar.gz
cpython-e812d29b52c597363d8d2c2615def653701a0efc.tar.bz2
Issue #7545: improve documentation of the `buffering` argument in io.open().
Diffstat (limited to 'Modules/_io')
-rw-r--r--Modules/_io/_iomodule.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/Modules/_io/_iomodule.c b/Modules/_io/_iomodule.c
index a2a6430..ca359bc 100644
--- a/Modules/_io/_iomodule.c
+++ b/Modules/_io/_iomodule.c
@@ -219,10 +219,20 @@ PyDoc_STRVAR(open_doc,
"returned as strings, the bytes having been first decoded using a\n"
"platform-dependent encoding or using the specified encoding if given.\n"
"\n"
-"buffering is an optional integer used to set the buffering policy. By\n"
-"default full buffering is on. Pass 0 to switch buffering off (only\n"
-"allowed in binary mode), 1 to set line buffering, and an integer > 1\n"
-"for full buffering.\n"
+"buffering is an optional integer used to set the buffering policy.\n"
+"Pass 0 to switch buffering off (only allowed in binary mode), 1 to select\n"
+"line buffering (only usable in text mode), and an integer > 1 to indicate\n"
+"the size of a fixed-size chunk buffer. When no buffering argument is\n"
+"given, the default buffering policy works as follows:\n"
+"\n"
+"* Binary files are buffered in fixed-size chunks; the size of the buffer\n"
+" is chosen using a heuristic trying to determine the underlying device's\n"
+" \"block size\" and falling back on `io.DEFAULT_BUFFER_SIZE`.\n"
+" On many systems, the buffer will typically be 4096 or 8192 bytes long.\n"
+"\n"
+"* \"Interactive\" text files (files for which isatty() returns True)\n"
+" use line buffering. Other text files use the policy described above\n"
+" for binary files.\n"
"\n"
"encoding is the name of the encoding used to decode or encode the\n"
"file. This should only be used in text mode. The default encoding is\n"