summaryrefslogtreecommitdiff
path: root/Lib/_pyio.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2012-06-05 13:43:22 +0200
committerVictor Stinner <victor.stinner@gmail.com>2012-06-05 13:43:22 +0200
commitf86a5e8a93ab293d4cc00a8f2835d6d2cd3baa69 (patch)
tree9d249e4c06f25885dc668edd529b1a4c802c898a /Lib/_pyio.py
parent91c5a34613fb918c79bb372723e10e106ad9a9be (diff)
downloadcpython-git-f86a5e8a93ab293d4cc00a8f2835d6d2cd3baa69.tar.gz
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 'Lib/_pyio.py')
-rw-r--r--Lib/_pyio.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/Lib/_pyio.py b/Lib/_pyio.py
index f66290fa51..b684a9f7cb 100644
--- a/Lib/_pyio.py
+++ b/Lib/_pyio.py
@@ -1448,7 +1448,7 @@ class TextIOWrapper(TextIOBase):
r"""Character and line based layer over a BufferedIOBase object, buffer.
encoding gives the name of the encoding that the stream will be
- decoded or encoded with. It defaults to locale.getpreferredencoding.
+ decoded or encoded with. It defaults to locale.getpreferredencoding(False).
errors determines the strictness of encoding and decoding (see the
codecs.register) and defaults to "strict".
@@ -1487,7 +1487,7 @@ class TextIOWrapper(TextIOBase):
# Importing locale may fail if Python is being built
encoding = "ascii"
else:
- encoding = locale.getpreferredencoding()
+ encoding = locale.getpreferredencoding(False)
if not isinstance(encoding, str):
raise ValueError("invalid encoding: %r" % encoding)