mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
bpo-42639: Cleanup atexitmodule.c (GH-23770)
* Rename "atexitmodule_state" to "struct atexit_state". * Rename "modstate" to "state". * Rename "self" parameter to "module". * test_atexit uses textwrap.dedent(). * Remove _Py_PyAtExit() function: inline it into atexit_exec(). * PyInterpreterState: rename pyexitfunc to atexit_func, rename pyexitmodule to atexit_module.
This commit is contained in:
parent
fdb9efce6a
commit
83d52044ae
5 changed files with 126 additions and 159 deletions
|
@ -2634,26 +2634,14 @@ Py_ExitStatusException(PyStatus status)
|
|||
|
||||
/* Clean up and exit */
|
||||
|
||||
/* For the atexit module. */
|
||||
void _Py_PyAtExit(void (*func)(PyObject *), PyObject *module)
|
||||
{
|
||||
PyInterpreterState *is = _PyInterpreterState_GET();
|
||||
|
||||
/* Guard against API misuse (see bpo-17852) */
|
||||
assert(is->pyexitfunc == NULL || is->pyexitfunc == func);
|
||||
|
||||
is->pyexitfunc = func;
|
||||
is->pyexitmodule = module;
|
||||
}
|
||||
|
||||
static void
|
||||
call_py_exitfuncs(PyThreadState *tstate)
|
||||
{
|
||||
PyInterpreterState *interp = tstate->interp;
|
||||
if (interp->pyexitfunc == NULL)
|
||||
if (interp->atexit_func == NULL)
|
||||
return;
|
||||
|
||||
(*interp->pyexitfunc)(interp->pyexitmodule);
|
||||
interp->atexit_func(interp->atexit_module);
|
||||
_PyErr_Clear(tstate);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue