Coverage Report

Created: 2026-12-01 06:09

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/cpython/Modules/clinic/atexitmodule.c.h
Line
Count
Source
1
/*[clinic input]
2
preserve
3
[clinic start generated code]*/
4
5
#include "pycore_modsupport.h"    // _PyArg_CheckPositional()
6
7
PyDoc_STRVAR(atexit_register__doc__,
8
"register($module, func, /, *args, **kwargs)\n"
9
"--\n"
10
"\n"
11
"Register a function to be executed upon normal program termination\n"
12
"\n"
13
"    func - function to be called at exit\n"
14
"    args - optional arguments to pass to func\n"
15
"    kwargs - optional keyword arguments to pass to func\n"
16
"\n"
17
"    func is returned to facilitate usage as a decorator.");
18
19
#define ATEXIT_REGISTER_METHODDEF    \
20
    {"register", _PyCFunction_CAST(atexit_register), METH_VARARGS|METH_KEYWORDS, atexit_register__doc__},
21
22
static PyObject *
23
atexit_register_impl(PyObject *module, PyObject *func, PyObject *args,
24
                     PyObject *kwargs);
25
26
static PyObject *
27
atexit_register(PyObject *module, PyObject *args, PyObject *kwargs)
28
10
{
29
10
    PyObject *return_value = NULL;
30
10
    PyObject *func;
31
10
    PyObject *__clinic_args = NULL;
32
10
    PyObject *__clinic_kwargs = NULL;
33
34
10
    if (!_PyArg_CheckPositional("register", PyTuple_GET_SIZE(args), 1, PY_SSIZE_T_MAX)) {
35
0
        goto exit;
36
0
    }
37
10
    func = PyTuple_GET_ITEM(args, 0);
38
10
    __clinic_args = PyTuple_GetSlice(args, 1, PY_SSIZE_T_MAX);
39
10
    if (!__clinic_args) {
40
0
        goto exit;
41
0
    }
42
10
    __clinic_kwargs = kwargs;
43
10
    return_value = atexit_register_impl(module, func, __clinic_args, __clinic_kwargs);
44
45
10
exit:
46
    /* Cleanup for args */
47
10
    Py_XDECREF(__clinic_args);
48
49
10
    return return_value;
50
10
}
51
/*[clinic end generated code: output=dd82692b8d449aef input=a9049054013a1b77]*/