Skip to content

Commit

Permalink
pythongh-108223: Add [NOGIL] marker to sys.version
Browse files Browse the repository at this point in the history
If Python was configured with --disable-gil, add " [NOGIL]" suffix to
sys.version. It should help users to check if they are running a
regular Python build with a GIL, or a custom Python build with the
new experimental no GIL.
  • Loading branch information
vstinner committed Aug 21, 2023
1 parent d63972e commit f4e41b8
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions Python/getversion.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,21 @@
#include "patchlevel.h"

static int initialized = 0;
static char version[250];
static char version[258];

void _Py_InitVersion(void)
{
if (initialized) {
return;
}
initialized = 1;
PyOS_snprintf(version, sizeof(version), "%.80s (%.80s) %.80s",
PY_VERSION, Py_GetBuildInfo(), Py_GetCompiler());
#ifdef Py_NOGIL
const char *gil = " [NOGIL]"; // 8 characters
#else
const char *gil = "";
#endif
PyOS_snprintf(version, sizeof(version), "%.80s (%.80s) %.80s%s",
PY_VERSION, Py_GetBuildInfo(), Py_GetCompiler(), gil);
}

const char *
Expand Down

0 comments on commit f4e41b8

Please sign in to comment.