Coverage Report

Created: 2026-10-17 06:15

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
    if (kwargs == NULL) {
43
10
        __clinic_kwargs = PyDict_New();
44
10
        if (__clinic_kwargs == NULL) {
45
0
            goto exit;
46
0
        }
47
10
    }
48
0
    else {
49
0
        __clinic_kwargs = Py_NewRef(kwargs);
50
0
    }
51
10
    return_value = atexit_register_impl(module, func, __clinic_args, __clinic_kwargs);
52
53
10
exit:
54
    /* Cleanup for args */
55
10
    Py_XDECREF(__clinic_args);
56
    /* Cleanup for kwargs */
57
10
    Py_XDECREF(__clinic_kwargs);
58
59
10
    return return_value;
60
10
}
61
/*[clinic end generated code: output=8fd8f691fdbc4e0a input=a9049054013a1b77]*/