mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
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:
parent
100964e031
commit
048a35659a
9 changed files with 189 additions and 16 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue