diff options
author | Alexey Izbyshev <izbyshev@ispras.ru> | 2018-10-20 00:22:31 (GMT) |
---|---|---|
committer | Victor Stinner <vstinner@redhat.com> | 2018-10-20 00:22:31 (GMT) |
commit | a2670565d8f5c502388378aba1fe73023fd8c8d4 (patch) | |
tree | a9f3a5f8e2a123aaff4f27a94c33580f0216dccd /Doc | |
parent | 4acf6c9d4be77b968fa498569d7a1545e5e77344 (diff) | |
download | cpython-a2670565d8f5c502388378aba1fe73023fd8c8d4.zip cpython-a2670565d8f5c502388378aba1fe73023fd8c8d4.tar.gz cpython-a2670565d8f5c502388378aba1fe73023fd8c8d4.tar.bz2 |
bpo-32236: open() emits RuntimeWarning if buffering=1 for binary mode (GH-4842)
If buffering=1 is specified for open() in binary mode, it is silently
treated as buffering=-1 (i.e., the default buffer size).
Coupled with the fact that line buffering is always supported in Python 2,
such behavior caused several issues (e.g., bpo-10344, bpo-21332).
Warn that line buffering is not supported if open() is called with
binary mode and buffering=1.
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/codecs.rst | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/Doc/library/codecs.rst b/Doc/library/codecs.rst index b9c04c2..b323ab5 100644 --- a/Doc/library/codecs.rst +++ b/Doc/library/codecs.rst @@ -174,7 +174,7 @@ recommended approach for working with encoded text files, this module provides additional utility functions and classes that allow the use of a wider range of codecs when working with binary files: -.. function:: open(filename, mode='r', encoding=None, errors='strict', buffering=1) +.. function:: open(filename, mode='r', encoding=None, errors='strict', buffering=-1) Open an encoded file using the given *mode* and return an instance of :class:`StreamReaderWriter`, providing transparent encoding/decoding. @@ -194,8 +194,8 @@ wider range of codecs when working with binary files: *errors* may be given to define the error handling. It defaults to ``'strict'`` which causes a :exc:`ValueError` to be raised in case an encoding error occurs. - *buffering* has the same meaning as for the built-in :func:`open` function. It - defaults to line buffered. + *buffering* has the same meaning as for the built-in :func:`open` function. + It defaults to -1 which means that the default buffer size will be used. .. function:: EncodedFile(file, data_encoding, file_encoding=None, errors='strict') |