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
_PyCoreConfig: add stdio_encoding and stdio_errors #78666
Comments
Currently, the code to select the encoding and error handler of sys.stdin, sys.stdout and sys.stderr is run later in Py_Initialize(). I propose to move most of this code into _PyCoreConfig_Read() and add stdio_encoding and stdio_errors to _PyCoreConfig to easily let Python embedders to select the encoding. Attached PR implements this idea. During Py_Initialize(), the code still reads the LC_CTYPE locale to choose the error handler if stdio_errors is NULL. This check cannot be done earlier, since the LC_CTYPE locale is only set to the user locale in Py_Initialize(): after _PyCoreConfig_Read(). The Py_SetStandardStreamEncoding() function has been added by Nick Coghlan in bpo-16129.
|
Oh wow, I didn't expect that it would be so complicated to "just" get the encoding of sys.stdout... I had to fix many bugs to be able to do that! |
Yeah, there were some good reasons I went with the relatively brute force option of provideding Blender with a new config API call back in bpo-16129 - as we've seen, actually fixing it properly has been a multi-year multi-person effort :) |
Yeah, I see ;-) Thanks for Py_SetStandardStreamEncoding(), it fixed Blender use case! |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: