New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove console encoding support from TextIOWrapper. #91526
Comments
`TextIOWrapper.__init__` calls `os.device_encoding(file.fileno())` if fileno is 0-2. But it is very rerely works, and never documented behavior.
|
Shouldn't What happens if you just call |
|
What file except WindowsConsoleIO has .encoding attribute? |
|
I thought it already looked for one, but no, it doesn't. |
…1529) `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.


Currently,
TextIOWrapper.__init__callsos.device_encoding(file.fileno())when encoding is not specified and fileno is 0-2 (e.g.open(0)).However,
sys.stdin,stdout, andstderrdon't use it even whenPYTHONLEGACYWINDOWSSTDIO=1.config->stdio_encodingis initialized byGetACP(), andcreate_stdio()passesconfig->stdio_encodingtoTextIOWrapper.How about removing
os.device_encoding(file.fileno())fromTextIOWrapper.__init__()?TextIOWrapper(sys.stdout)cause mojibake when sys.stdout is WindowsConsoleIOPYTHONLEGACYWINDOWSSTDIOI know is this. But this use case don't create TextIOWrapper for fd=0,1,2.TextIOWrapper.__init__complicated and inconsistent.create_stdio().create_stdio()has special case for WindowsConsoleIO already. (here)Ping: @vstinner @eryksun @zooba
The text was updated successfully, but these errors were encountered: