diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst index f5e4c1a8640f45..644bbe615f7c9e 100644 --- a/Doc/library/functions.rst +++ b/Doc/library/functions.rst @@ -1180,8 +1180,9 @@ 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 - in bytes of a fixed-size chunk buffer. Note that specifying a buffer size this + buffering (only usable in text mode), an integer > 1 to indicate the size + in bytes of a fixed-size chunk buffer, or -1 to use the default buffering + policy. 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 diff --git a/Lib/_pyio.py b/Lib/_pyio.py index 0bfdeaafae274b..9be3c873660bcf 100644 --- a/Lib/_pyio.py +++ b/Lib/_pyio.py @@ -122,8 +122,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 - the size of a fixed-size chunk buffer. When no buffering argument is + line buffering (only usable in text mode), an integer > 1 to indicate + the size of a fixed-size chunk buffer, or -1 to use the default buffering + policy. 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 diff --git a/Modules/_io/_iomodule.c b/Modules/_io/_iomodule.c index 38ef24637b7318..f8a3fd1ed218e0 100644 --- a/Modules/_io/_iomodule.c +++ b/Modules/_io/_iomodule.c @@ -123,8 +123,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 -the size of a fixed-size chunk buffer. When no buffering argument is +line buffering (only usable in text mode), an integer > 1 to indicate +the size of a fixed-size chunk buffer, or -1 to use the default buffering +policy. 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 @@ -196,7 +197,7 @@ static PyObject * _io_open_impl(PyObject *module, PyObject *file, const char *mode, int buffering, const char *encoding, const char *errors, const char *newline, int closefd, PyObject *opener) -/*[clinic end generated code: output=aefafc4ce2b46dc0 input=5bb37f174cb2fb11]*/ +/*[clinic end generated code: output=aefafc4ce2b46dc0 input=e90b1875043160db]*/ { unsigned i; diff --git a/Modules/_io/clinic/_iomodule.c.h b/Modules/_io/clinic/_iomodule.c.h index 0249dd184b1d35..72bacf605a9ca0 100644 --- a/Modules/_io/clinic/_iomodule.c.h +++ b/Modules/_io/clinic/_iomodule.c.h @@ -53,9 +53,10 @@ PyDoc_STRVAR(_io_open__doc__, "\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" +"line buffering (only usable in text mode), an integer > 1 to indicate\n" +"the size of a fixed-size chunk buffer, or -1 to use the default buffering\n" +"policy. When no buffering argument is given, the default buffering policy\n" +"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" @@ -355,4 +356,4 @@ _io_open_code(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObjec exit: return return_value; } -/*[clinic end generated code: output=c4d7e4ef878985f8 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=262fbd17bd4cc08b input=a9049054013a1b77]*/