diff options
author | Victor Stinner <vstinner@python.org> | 2021-02-19 14:10:45 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-19 14:10:45 (GMT) |
commit | bcb094b41f7fe4dd1686c50891d85632fcf0d481 (patch) | |
tree | 72ae3916ace264f291a89f288ff199a36ead54f4 /Modules | |
parent | a486054b24658fa623e030ddd4cc0cbfcac54ab0 (diff) | |
download | cpython-bcb094b41f7fe4dd1686c50891d85632fcf0d481.zip cpython-bcb094b41f7fe4dd1686c50891d85632fcf0d481.tar.gz cpython-bcb094b41f7fe4dd1686c50891d85632fcf0d481.tar.bz2 |
bpo-43268: Pass interp rather than tstate to internal functions (GH-24580)
Pass the current interpreter (interp) rather than the current Python
thread state (tstate) to internal functions which only use the
interpreter.
Modified functions:
* _PyXXX_Fini() and _PyXXX_ClearFreeList() functions
* _PyEval_SignalAsyncExc(), make_pending_calls()
* _PySys_GetObject(), sys_set_object(), sys_set_object_id(), sys_set_object_str()
* should_audit(), set_flags_from_config(), make_flags()
* _PyAtExit_Call()
* init_stdio_encoding()
* etc.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/atexitmodule.c | 8 | ||||
-rw-r--r-- | Modules/gcmodule.c | 30 |
2 files changed, 19 insertions, 19 deletions
diff --git a/Modules/atexitmodule.c b/Modules/atexitmodule.c index 49e2a75..e536b4a 100644 --- a/Modules/atexitmodule.c +++ b/Modules/atexitmodule.c @@ -52,9 +52,9 @@ atexit_cleanup(struct atexit_state *state) PyStatus -_PyAtExit_Init(PyThreadState *tstate) +_PyAtExit_Init(PyInterpreterState *interp) { - struct atexit_state *state = &tstate->interp->atexit; + struct atexit_state *state = &interp->atexit; // _PyAtExit_Init() must only be called once assert(state->callbacks == NULL); @@ -109,9 +109,9 @@ atexit_callfuncs(struct atexit_state *state) void -_PyAtExit_Call(PyThreadState *tstate) +_PyAtExit_Call(PyInterpreterState *interp) { - struct atexit_state *state = &tstate->interp->atexit; + struct atexit_state *state = &interp->atexit; atexit_callfuncs(state); } diff --git a/Modules/gcmodule.c b/Modules/gcmodule.c index f0d5699..21f6bd1 100644 --- a/Modules/gcmodule.c +++ b/Modules/gcmodule.c @@ -161,9 +161,9 @@ _PyGC_InitState(GCState *gcstate) PyStatus -_PyGC_Init(PyThreadState *tstate) +_PyGC_Init(PyInterpreterState *interp) { - GCState *gcstate = &tstate->interp->gc; + GCState *gcstate = &interp->gc; gcstate->garbage = PyList_New(0); if (gcstate->garbage == NULL) { @@ -1036,15 +1036,15 @@ delete_garbage(PyThreadState *tstate, GCState *gcstate, * Clearing the free lists may give back memory to the OS earlier. */ static void -clear_freelists(PyThreadState *tstate) +clear_freelists(PyInterpreterState *interp) { - _PyFrame_ClearFreeList(tstate); - _PyTuple_ClearFreeList(tstate); - _PyFloat_ClearFreeList(tstate); - _PyList_ClearFreeList(tstate); - _PyDict_ClearFreeList(tstate); - _PyAsyncGen_ClearFreeLists(tstate); - _PyContext_ClearFreeList(tstate); + _PyFrame_ClearFreeList(interp); + _PyTuple_ClearFreeList(interp); + _PyFloat_ClearFreeList(interp); + _PyList_ClearFreeList(interp); + _PyDict_ClearFreeList(interp); + _PyAsyncGen_ClearFreeLists(interp); + _PyContext_ClearFreeList(interp); } // Show stats for objects in each generations @@ -1323,7 +1323,7 @@ gc_collect_main(PyThreadState *tstate, int generation, /* Clear free list only during the collection of the highest * generation */ if (generation == NUM_GENERATIONS-1) { - clear_freelists(tstate); + clear_freelists(tstate->interp); } if (_PyErr_Occurred(tstate)) { @@ -2092,9 +2092,9 @@ _PyGC_CollectNoFail(PyThreadState *tstate) } void -_PyGC_DumpShutdownStats(PyThreadState *tstate) +_PyGC_DumpShutdownStats(PyInterpreterState *interp) { - GCState *gcstate = &tstate->interp->gc; + GCState *gcstate = &interp->gc; if (!(gcstate->debug & DEBUG_SAVEALL) && gcstate->garbage != NULL && PyList_GET_SIZE(gcstate->garbage) > 0) { const char *message; @@ -2129,9 +2129,9 @@ _PyGC_DumpShutdownStats(PyThreadState *tstate) } void -_PyGC_Fini(PyThreadState *tstate) +_PyGC_Fini(PyInterpreterState *interp) { - GCState *gcstate = &tstate->interp->gc; + GCState *gcstate = &interp->gc; Py_CLEAR(gcstate->garbage); Py_CLEAR(gcstate->callbacks); } |