diff options
author | Victor Stinner <vstinner@python.org> | 2020-04-13 01:04:28 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-13 01:04:28 (GMT) |
commit | da7933ecc30e37b119756cb02b89a6ad99db22e0 (patch) | |
tree | e6c7227f2ded7b7354fb027342fa977f70808d10 /Python/pystate.c | |
parent | 14d5331eb5e6c38be12bad421bd59ad0fac9e448 (diff) | |
download | cpython-da7933ecc30e37b119756cb02b89a6ad99db22e0.zip cpython-da7933ecc30e37b119756cb02b89a6ad99db22e0.tar.gz cpython-da7933ecc30e37b119756cb02b89a6ad99db22e0.tar.bz2 |
bpo-40268: Add _PyInterpreterState_GetConfig() (GH-19492)
Don't access PyInterpreterState.config member directly anymore, but
use new functions:
* _PyInterpreterState_GetConfig()
* _PyInterpreterState_SetConfig()
* _Py_GetConfig()
Diffstat (limited to 'Python/pystate.c')
-rw-r--r-- | Python/pystate.c | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/Python/pystate.c b/Python/pystate.c index 0539096..19beaf0 100644 --- a/Python/pystate.c +++ b/Python/pystate.c @@ -790,7 +790,7 @@ _PyInterpreterState_ClearModules(PyInterpreterState *interp) void PyThreadState_Clear(PyThreadState *tstate) { - int verbose = tstate->interp->config.verbose; + int verbose = _PyInterpreterState_GetConfig(tstate->interp)->verbose; if (verbose && tstate->frame != NULL) { /* bpo-20526: After the main thread calls @@ -1808,6 +1808,30 @@ _PyInterpreterState_SetEvalFrameFunc(PyInterpreterState *interp, interp->eval_frame = eval_frame; } + +const PyConfig* +_PyInterpreterState_GetConfig(PyInterpreterState *interp) +{ + return &interp->config; +} + + +PyStatus +_PyInterpreterState_SetConfig(PyInterpreterState *interp, + const PyConfig *config) +{ + return _PyConfig_Copy(&interp->config, config); +} + + +const PyConfig* +_Py_GetConfig(void) +{ + assert(PyGILState_Check()); + PyThreadState *tstate = _PyThreadState_GET(); + return _PyInterpreterState_GetConfig(tstate->interp); +} + #ifdef __cplusplus } #endif |