bpo-36763: Add _PyCoreConfig_SetString() (GH-13035)

Add 3 new config methods:

* _PyCoreConfig_SetString()
* _PyCoreConfig_SetWideString()
* _PyCoreConfig_SetWideStringFromString()

Changes:

* _PyCoreConfig_Copy() returns _PyInitError.
* Add CONFIG_GET_ENV_DUP().
This commit is contained in:
Victor Stinner 2019-05-01 15:22:52 +02:00 committed by GitHub
parent 2fc936ed24
commit 1a9f0d8efd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 251 additions and 168 deletions

View file

@ -472,6 +472,7 @@ _Py_Initialize_ReconfigureCore(_PyRuntimeState *runtime,
PyInterpreterState **interp_p,
const _PyCoreConfig *core_config)
{
_PyInitError err;
PyThreadState *tstate = _PyThreadState_GET();
if (!tstate) {
return _Py_INIT_ERR("failed to read thread state");
@ -485,13 +486,14 @@ _Py_Initialize_ReconfigureCore(_PyRuntimeState *runtime,
_PyCoreConfig_Write(core_config, runtime);
if (_PyCoreConfig_Copy(&interp->core_config, core_config) < 0) {
return _Py_INIT_NO_MEMORY();
err = _PyCoreConfig_Copy(&interp->core_config, core_config);
if (_Py_INIT_FAILED(err)) {
return err;
}
core_config = &interp->core_config;
if (core_config->_install_importlib) {
_PyInitError err = _PyCoreConfig_SetPathConfig(core_config);
err = _PyCoreConfig_SetPathConfig(core_config);
if (_Py_INIT_FAILED(err)) {
return err;
}
@ -545,8 +547,9 @@ pycore_create_interpreter(_PyRuntimeState *runtime,
}
*interp_p = interp;
if (_PyCoreConfig_Copy(&interp->core_config, core_config) < 0) {
return _Py_INIT_NO_MEMORY();
_PyInitError err = _PyCoreConfig_Copy(&interp->core_config, core_config);
if (_Py_INIT_FAILED(err)) {
return err;
}
core_config = &interp->core_config;
@ -804,8 +807,9 @@ pyinit_coreconfig(_PyRuntimeState *runtime,
_PyInitError err;
if (src_config) {
if (_PyCoreConfig_Copy(config, src_config) < 0) {
return _Py_INIT_NO_MEMORY();
err = _PyCoreConfig_Copy(config, src_config);
if (_Py_INIT_FAILED(err)) {
return err;
}
}
@ -1433,8 +1437,9 @@ new_interpreter(PyThreadState **tstate_p)
core_config = &main_interp->core_config;
}
if (_PyCoreConfig_Copy(&interp->core_config, core_config) < 0) {
return _Py_INIT_NO_MEMORY();
err = _PyCoreConfig_Copy(&interp->core_config, core_config);
if (_Py_INIT_FAILED(err)) {
return err;
}
core_config = &interp->core_config;