bpo-34485: Add _Py_ClearStandardStreamEncoding() (GH-8982)

* Move Py_SetStandardStreamEncoding() from pylifecycle.c
  to coreconfig.c
* Add _Py_ClearStandardStreamEncoding() private function.
* pymain_free() now calls _Py_ClearStandardStreamEncoding().
* Add assertions add the end of _PyCoreConfig_Read()
* _PyCoreConfig_Copy(): rename COPY_STR_ATTR() macro
  to COPY_WSTR_ATTR().
* Fix get_stdio_errors() indentation.
This commit is contained in:
Victor Stinner 2018-08-29 01:29:06 +02:00 committed by GitHub
parent 2c8ddcf4f1
commit 124b9eb4e4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 111 additions and 97 deletions

View file

@ -466,6 +466,7 @@ pymain_free(_PyMain *pymain)
remain valid after Py_Finalize(), since
Py_Initialize()-Py_Finalize() can be called multiple times. */
_PyPathConfig_ClearGlobal();
_Py_ClearStandardStreamEncoding();
/* Force the allocator used by pymain_read_conf() */
PyMemAllocatorEx old_alloc;
@ -1262,7 +1263,6 @@ pymain_read_conf_impl(_PyMain *pymain, _PyCoreConfig *config,
return -1;
}
assert(config->use_environment >= 0);
if (config->use_environment) {
err = cmdline_init_env_warnoptions(pymain, config, cmdline);
if (_Py_INIT_FAILED(err)) {