diff options
author | Nick Coghlan <ncoghlan@gmail.com> | 2013-10-17 12:35:35 (GMT) |
---|---|---|
committer | Nick Coghlan <ncoghlan@gmail.com> | 2013-10-17 12:35:35 (GMT) |
commit | 7d270ee05d7553aea1052cf7957358888ac8ad85 (patch) | |
tree | 4b3252363aac65d60104ef68dbc2d5174c0d8a91 /Doc/c-api/init.rst | |
parent | 26f92680da305a4f3007c47e11cced893991ec70 (diff) | |
download | cpython-7d270ee05d7553aea1052cf7957358888ac8ad85.zip cpython-7d270ee05d7553aea1052cf7957358888ac8ad85.tar.gz cpython-7d270ee05d7553aea1052cf7957358888ac8ad85.tar.bz2 |
Issue #16129: Add `Py_SetStandardStreamEncoding`
This new pre-initialization API allows embedding
applications like Blender to force a particular
encoding and error handler for the standard IO streams.
Also refactors Modules/_testembed.c to let us start
testing multiple embedding scenarios.
(Initial patch by Bastien Montagne)
Diffstat (limited to 'Doc/c-api/init.rst')
-rw-r--r-- | Doc/c-api/init.rst | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/Doc/c-api/init.rst b/Doc/c-api/init.rst index 9ed2a3a..1a54321 100644 --- a/Doc/c-api/init.rst +++ b/Doc/c-api/init.rst @@ -86,6 +86,33 @@ Process-wide parameters ======================= +.. c:function:: int Py_SetStandardStreamEncoding(char *encoding, char *errors) + + .. index:: + single: Py_Initialize() + single: main() + triple: stdin; stdout; sdterr + + This function should be called before :c:func:`Py_Initialize`. It + specifies which encoding and error handling to use with standard io, + with the same meanings as in :func:`str.encode`. + + It overrides :envvar:`PYTHONIOENCODING` values, and allows embedding code + to control io encoding when the environment variable does not work. + + ``encoding`` and/or ``errors`` may be NULL to use + :envvar:`PYTHONIOENCODING` and/or default values (depending on other + settings). + + Note that :data:`sys.stderr` always uses the "backslashreplace" error + handler, regardless of this (or any other) setting. + + If :c:func:`Py_Finalize` is called, this function will need to be called + again in order to affect subsequent calls to :c:func:`Py_Initialize`. + + Returns 0 if successful. + + .. c:function:: void Py_SetProgramName(wchar_t *name) .. index:: |