bpo-42260: Add _PyInterpreterState_SetConfig() (GH-23158)

* Inline _PyInterpreterState_SetConfig(): replace it with
  _PyConfig_Copy().
* Add _PyErr_SetFromPyStatus()
* Add _PyInterpreterState_GetConfigCopy()
* Add a new _PyInterpreterState_SetConfig() function.
* Add an unit which gets, modifies, and sets the config.
This commit is contained in:
Victor Stinner 2020-11-05 00:45:56 +01:00 committed by GitHub
parent 100964e031
commit 048a35659a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 189 additions and 16 deletions

View file

@ -778,7 +778,7 @@ PyState_RemoveModule(struct PyModuleDef* def)
return PyList_SetItem(interp->modules_by_index, index, Py_None);
}
/* Used by PyImport_Cleanup() */
// Used by finalize_modules()
void
_PyInterpreterState_ClearModules(PyInterpreterState *interp)
{
@ -1920,11 +1920,17 @@ _PyInterpreterState_GetConfig(PyInterpreterState *interp)
}
PyStatus
_PyInterpreterState_SetConfig(PyInterpreterState *interp,
const PyConfig *config)
int
_PyInterpreterState_GetConfigCopy(PyConfig *config)
{
return _PyConfig_Copy(&interp->config, config);
PyInterpreterState *interp = PyInterpreterState_Get();
PyStatus status = _PyConfig_Copy(config, &interp->config);
if (PyStatus_Exception(status)) {
_PyErr_SetFromPyStatus(status);
return -1;
}
return 0;
}