diff options
author | Victor Stinner <vstinner@python.org> | 2020-11-04 23:45:56 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-04 23:45:56 (GMT) |
commit | 048a35659aa8074afe7d7d054e7cea1f8ee6d366 (patch) | |
tree | e9a019387bbd73cdbfcdceb76af7d21e15bc30d0 /Python/pystate.c | |
parent | 100964e0310d3a2040d0db976f7984d0507b2dbd (diff) | |
download | cpython-048a35659aa8074afe7d7d054e7cea1f8ee6d366.zip cpython-048a35659aa8074afe7d7d054e7cea1f8ee6d366.tar.gz cpython-048a35659aa8074afe7d7d054e7cea1f8ee6d366.tar.bz2 |
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.
Diffstat (limited to 'Python/pystate.c')
-rw-r--r-- | Python/pystate.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/Python/pystate.c b/Python/pystate.c index c9882a7..600cc5e 100644 --- a/Python/pystate.c +++ b/Python/pystate.c @@ -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; } |