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 /Include/cpython | |
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 'Include/cpython')
-rw-r--r-- | Include/cpython/pystate.h | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/Include/cpython/pystate.h b/Include/cpython/pystate.h index 25522b4..0e6cc29 100644 --- a/Include/cpython/pystate.h +++ b/Include/cpython/pystate.h @@ -193,6 +193,36 @@ PyAPI_FUNC(void) _PyInterpreterState_SetEvalFrameFunc( PyAPI_FUNC(const PyConfig*) _PyInterpreterState_GetConfig(PyInterpreterState *interp); +/* Get a copy of the current interpreter configuration. + + Return 0 on success. Raise an exception and return -1 on error. + + The caller must initialize 'config', using PyConfig_InitPythonConfig() + for example. + + Python must be preinitialized to call this method. + The caller must hold the GIL. */ +PyAPI_FUNC(int) _PyInterpreterState_GetConfigCopy( + struct PyConfig *config); + +/* Set the configuration of the current interpreter. + + This function should be called during or just after the Python + initialization. + + Update the sys module with the new configuration. If the sys module was + modified directly after the Python initialization, these changes are lost. + + Some configuration like faulthandler or warnoptions can be updated in the + configuration, but don't reconfigure Python (don't enable/disable + faulthandler and don't reconfigure warnings filters). + + Return 0 on success. Raise an exception and return -1 on error. + + The configuration should come from _PyInterpreterState_GetConfigCopy(). */ +PyAPI_FUNC(int) _PyInterpreterState_SetConfig( + const struct PyConfig *config); + // Get the configuration of the currrent interpreter. // The caller must hold the GIL. PyAPI_FUNC(const PyConfig*) _Py_GetConfig(void); |