diff options
author | Victor Stinner <vstinner@redhat.com> | 2019-05-16 16:30:15 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-16 16:30:15 (GMT) |
commit | 54b43bb3bb88339b63182b3515cda3efa530ed62 (patch) | |
tree | 948f321e0b2b9925eec945d316cd3e010da69852 /Python | |
parent | 9ef5dcaa0b3c7c7ba28dbb3ec0c9507d9d05e3a9 (diff) | |
download | cpython-54b43bb3bb88339b63182b3515cda3efa530ed62.zip cpython-54b43bb3bb88339b63182b3515cda3efa530ed62.tar.gz cpython-54b43bb3bb88339b63182b3515cda3efa530ed62.tar.bz2 |
bpo-36763: Add _PyCoreConfig.configure_c_stdio (GH-13363)
Add tests for configure_c_stdio and pathconfig_warnings parameters.
Diffstat (limited to 'Python')
-rw-r--r-- | Python/coreconfig.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/Python/coreconfig.c b/Python/coreconfig.c index 8a5e5d5..e51bf94 100644 --- a/Python/coreconfig.c +++ b/Python/coreconfig.c @@ -654,6 +654,7 @@ _PyCoreConfig_Copy(_PyCoreConfig *config, const _PyCoreConfig *config2) COPY_ATTR(verbose); COPY_ATTR(quiet); COPY_ATTR(user_site_directory); + COPY_ATTR(configure_c_stdio); COPY_ATTR(buffered_stdio); COPY_WSTR_ATTR(filesystem_encoding); COPY_WSTR_ATTR(filesystem_errors); @@ -755,6 +756,7 @@ _PyCoreConfig_AsDict(const _PyCoreConfig *config) SET_ITEM_INT(verbose); SET_ITEM_INT(quiet); SET_ITEM_INT(user_site_directory); + SET_ITEM_INT(configure_c_stdio); SET_ITEM_INT(buffered_stdio); SET_ITEM_WSTR(stdio_encoding); SET_ITEM_WSTR(stdio_errors); @@ -1582,7 +1584,6 @@ config_read(_PyCoreConfig *config, _PyPreCmdline *cmdline) return _Py_INIT_NO_MEMORY(); } } - return _Py_INIT_OK(); } @@ -1632,7 +1633,10 @@ void _PyCoreConfig_Write(const _PyCoreConfig *config, _PyRuntimeState *runtime) { _PyCoreConfig_SetGlobalConfig(config); - config_init_stdio(config); + + if (config->configure_c_stdio) { + config_init_stdio(config); + } /* Write the new pre-configuration into _PyRuntime */ _PyPreConfig *preconfig = &runtime->preconfig; @@ -2067,6 +2071,9 @@ config_read_cmdline(_PyCoreConfig *config, _PyPreCmdline *precmdline) if (config->parse_argv < 0) { config->parse_argv = 1; } + if (config->configure_c_stdio < 0) { + config->configure_c_stdio = 1; + } if (config->parse_argv) { int opt_index; @@ -2171,7 +2178,9 @@ _PyCoreConfig_SetWideArgv(_PyCoreConfig *config, int argc, wchar_t **argv) * Command line arguments * Environment variables - * Py_xxx global configuration variables */ + * Py_xxx global configuration variables + + The only side effects are to modify config and to call _Py_SetArgcArgv(). */ _PyInitError _PyCoreConfig_Read(_PyCoreConfig *config) { @@ -2227,14 +2236,19 @@ _PyCoreConfig_Read(_PyCoreConfig *config) assert(config->quiet >= 0); assert(config->user_site_directory >= 0); assert(config->parse_argv >= 0); + assert(config->configure_c_stdio >= 0); assert(config->buffered_stdio >= 0); assert(config->program_name != NULL); assert(config->program != NULL); assert(_PyWstrList_CheckConsistency(&config->argv)); + /* sys.argv must be non-empty: empty argv is replaced with [''] */ + assert(config->argv.length >= 1); assert(_PyWstrList_CheckConsistency(&config->xoptions)); assert(_PyWstrList_CheckConsistency(&config->warnoptions)); assert(_PyWstrList_CheckConsistency(&config->module_search_paths)); if (config->_install_importlib) { + assert(config->use_module_search_paths != 0); + /* don't check config->module_search_paths */ assert(config->executable != NULL); assert(config->prefix != NULL); assert(config->base_prefix != NULL); |