diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2012-06-05 11:43:22 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2012-06-05 11:43:22 (GMT) |
commit | f86a5e8a93ab293d4cc00a8f2835d6d2cd3baa69 (patch) | |
tree | 9d249e4c06f25885dc668edd529b1a4c802c898a /Doc | |
parent | 91c5a34613fb918c79bb372723e10e106ad9a9be (diff) | |
download | cpython-f86a5e8a93ab293d4cc00a8f2835d6d2cd3baa69.zip cpython-f86a5e8a93ab293d4cc00a8f2835d6d2cd3baa69.tar.gz cpython-f86a5e8a93ab293d4cc00a8f2835d6d2cd3baa69.tar.bz2 |
Close #11022: TextIOWrapper doesn't call locale.setlocale() anymore
open() and io.TextIOWrapper are now calling locale.getpreferredencoding(False)
instead of locale.getpreferredencoding() in text mode if the encoding is not
specified. Don't change temporary the locale encoding using locale.setlocale(),
use the current locale encoding instead of the user preferred encoding.
Explain also in open() documentation that locale.getpreferredencoding(False) is
called if the encoding is not specified.
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/functions.rst | 7 | ||||
-rw-r--r-- | Doc/library/io.rst | 8 |
2 files changed, 11 insertions, 4 deletions
diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst index d5ac23e..5254299 100644 --- a/Doc/library/functions.rst +++ b/Doc/library/functions.rst @@ -800,9 +800,10 @@ are always available. They are listed here in alphabetical order. already exists), ``'x'`` for exclusive creation and ``'a'`` for appending (which on *some* Unix systems, means that *all* writes append to the end of the file regardless of the current seek position). In text mode, if - *encoding* is not specified the encoding used is platform dependent. (For - reading and writing raw bytes use binary mode and leave *encoding* - unspecified.) The available modes are: + *encoding* is not specified the encoding used is platform dependent: + ``locale.getpreferredencoding(False)`` is called to get the current locale + encoding. (For reading and writing raw bytes use binary mode and leave + *encoding* unspecified.) The available modes are: ========= =============================================================== Character Meaning diff --git a/Doc/library/io.rst b/Doc/library/io.rst index 4d564bb..e30a016 100644 --- a/Doc/library/io.rst +++ b/Doc/library/io.rst @@ -752,7 +752,7 @@ Text I/O It inherits :class:`TextIOBase`. *encoding* gives the name of the encoding that the stream will be decoded or - encoded with. It defaults to :func:`locale.getpreferredencoding`. + encoded with. It defaults to ``locale.getpreferredencoding(False)``. *errors* is an optional string that specifies how encoding and decoding errors are to be handled. Pass ``'strict'`` to raise a :exc:`ValueError` @@ -784,6 +784,12 @@ Text I/O .. versionchanged:: 3.3 The *write_through* argument has been added. + .. versionchanged:: 3.3 + The default *encoding* is now ``locale.getpreferredencoding(False)`` + instead of ``locale.getpreferredencoding()``. Don't change temporary the + locale encoding using :func:`locale.setlocale`, use the current locale + encoding instead of the user preferred encoding. + :class:`TextIOWrapper` provides one attribute in addition to those of :class:`TextIOBase` and its parents: |