[New-bugs-announce] [issue34485] _PyCoreConfig: add stdio_encoding and stdio_errors

STINNER Victor report at bugs.python.org
Thu Aug 23 19:44:09 EDT 2018


New submission from STINNER Victor <vstinner at redhat.com>:

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.

    This new pre-initialization API allows embedding
    applications like Blender to force a particular
    encoding and error handler for the standard IO streams.

----------
messages: 323980
nosy: vstinner
priority: normal
severity: normal
status: open
title: _PyCoreConfig: add stdio_encoding and stdio_errors
versions: Python 3.8

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue34485>
_______________________________________


More information about the New-bugs-announce mailing list