From b1aa0380f62c6e5504b01d0a5b70258d8b0861ba Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Mon, 21 Aug 2023 21:48:37 +0200 Subject: [PATCH] gh-108223: Add [NOGIL] marker to sys.version If Python is 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. sys.version is commonly requested in bug reports: knowing if Python was configured with --disable-gil should ease debug. Example on Linux with --disable-gil: $ ./python -VV Python 3.13.0a0 (heads/main-dirty:d63972e289, Aug 21 2023, 21:43:45) [GCC 13.2.1 20230728 (Red Hat 13.2.1-1)] [NOGIL] --- Python/getversion.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Python/getversion.c b/Python/getversion.c index 5db836ab4bfd6d..e5ac6da92ef262 100644 --- a/Python/getversion.c +++ b/Python/getversion.c @@ -6,7 +6,7 @@ #include "patchlevel.h" static int initialized = 0; -static char version[250]; +static char version[258]; void _Py_InitVersion(void) { @@ -14,8 +14,13 @@ void _Py_InitVersion(void) 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 * pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy