mirror of
https://github.com/python/cpython.git
synced 2025-10-09 08:31:26 +00:00
gh-91526: io: Remove device encoding support from TextIOWrapper (GH-91529)
`TextIOWrapper.__init__()` called `os.device_encoding(file.fileno())` if fileno is 0-2 and encoding=None. But it is very rarely works, and never documented behavior.
This commit is contained in:
parent
39a54ba638
commit
6fdb62b1fa
4 changed files with 9 additions and 70 deletions
|
@ -2021,14 +2021,6 @@ class TextIOWrapper(TextIOBase):
|
|||
self._check_newline(newline)
|
||||
encoding = text_encoding(encoding)
|
||||
|
||||
if encoding == "locale" and sys.platform == "win32":
|
||||
# On Unix, os.device_encoding() returns "utf-8" instead of locale encoding
|
||||
# in the UTF-8 mode. So we use os.device_encoding() only on Windows.
|
||||
try:
|
||||
encoding = os.device_encoding(buffer.fileno()) or "locale"
|
||||
except (AttributeError, UnsupportedOperation):
|
||||
pass
|
||||
|
||||
if encoding == "locale":
|
||||
try:
|
||||
import locale
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue