Coverage Report

Created: 2025-07-11 06:59

/src/Python-3.8.3/Modules/getbuildinfo.c
Line
Count
Source (jump to first uncovered line)
1
#include "Python.h"
2
3
#ifndef DONT_HAVE_STDIO_H
4
#include <stdio.h>
5
#endif
6
7
#ifndef DATE
8
#ifdef __DATE__
9
14
#define DATE __DATE__
10
#else
11
#define DATE "xx/xx/xx"
12
#endif
13
#endif
14
15
#ifndef TIME
16
#ifdef __TIME__
17
14
#define TIME __TIME__
18
#else
19
#define TIME "xx:xx:xx"
20
#endif
21
#endif
22
23
/* XXX Only unix build process has been tested */
24
#ifndef GITVERSION
25
#define GITVERSION ""
26
#endif
27
#ifndef GITTAG
28
#define GITTAG ""
29
#endif
30
#ifndef GITBRANCH
31
#define GITBRANCH ""
32
#endif
33
34
const char *
35
Py_GetBuildInfo(void)
36
14
{
37
14
    static char buildinfo[50 + sizeof(GITVERSION) +
38
14
                          ((sizeof(GITTAG) > sizeof(GITBRANCH)) ?
39
14
                           sizeof(GITTAG) : sizeof(GITBRANCH))];
40
14
    const char *revision = _Py_gitversion();
41
14
    const char *sep = *revision ? ":" : "";
42
14
    const char *gitid = _Py_gitidentifier();
43
14
    if (!(*gitid))
44
14
        gitid = "default";
45
14
    PyOS_snprintf(buildinfo, sizeof(buildinfo),
46
14
                  "%s%s%s, %.20s, %.9s", gitid, sep, revision,
47
14
                  DATE, TIME);
48
14
    return buildinfo;
49
14
}
50
51
const char *
52
_Py_gitversion(void)
53
28
{
54
28
    return GITVERSION;
55
28
}
56
57
const char *
58
_Py_gitidentifier(void)
59
28
{
60
28
    const char *gittag, *gitid;
61
28
    gittag = GITTAG;
62
28
    if ((*gittag) && strcmp(gittag, "undefined") != 0)
63
0
        gitid = gittag;
64
28
    else
65
28
        gitid = GITBRANCH;
66
28
    return gitid;
67
28
}