From 1c1ab557b129ad31af22e4495d6092881ab86002 Mon Sep 17 00:00:00 2001 From: Donghee Na Date: Sat, 18 May 2024 10:18:36 -0400 Subject: [PATCH 1/2] gh-119132: Display free-threading information through -VV --- .../Build/2024-05-18-10-18-16.gh-issue-119132.mQ0XKg.rst | 2 ++ Python/initconfig.c | 5 +++++ 2 files changed, 7 insertions(+) create mode 100644 Misc/NEWS.d/next/Build/2024-05-18-10-18-16.gh-issue-119132.mQ0XKg.rst diff --git a/Misc/NEWS.d/next/Build/2024-05-18-10-18-16.gh-issue-119132.mQ0XKg.rst b/Misc/NEWS.d/next/Build/2024-05-18-10-18-16.gh-issue-119132.mQ0XKg.rst new file mode 100644 index 00000000000000..87d80a290e5095 --- /dev/null +++ b/Misc/NEWS.d/next/Build/2024-05-18-10-18-16.gh-issue-119132.mQ0XKg.rst @@ -0,0 +1,2 @@ +python -VV now display whether it is the free-threaded or not. Patch By +Donghee Na. diff --git a/Python/initconfig.c b/Python/initconfig.c index a28c08c5318ddc..4996439be680f9 100644 --- a/Python/initconfig.c +++ b/Python/initconfig.c @@ -2596,8 +2596,13 @@ config_parse_cmdline(PyConfig *config, PyWideStringList *warnoptions, } while (1); if (print_version) { +#ifdef Py_GIL_DISABLED + printf("Python %s (free-threading)\n", + (print_version >= 2) ? Py_GetVersion() : PY_VERSION); +#else printf("Python %s\n", (print_version >= 2) ? Py_GetVersion() : PY_VERSION); +#endif return _PyStatus_EXIT(0); } From aa0d0c811868ec061f00f0813d51ab10d9034fb5 Mon Sep 17 00:00:00 2001 From: Donghee Na Date: Sat, 18 May 2024 11:14:59 -0400 Subject: [PATCH 2/2] Update Python/initconfig.c Co-authored-by: Victor Stinner --- Python/initconfig.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Python/initconfig.c b/Python/initconfig.c index 4996439be680f9..a9875d6d42818d 100644 --- a/Python/initconfig.c +++ b/Python/initconfig.c @@ -2596,12 +2596,12 @@ config_parse_cmdline(PyConfig *config, PyWideStringList *warnoptions, } while (1); if (print_version) { + const char *version; + version = (print_version >= 2) ? Py_GetVersion() : PY_VERSION; #ifdef Py_GIL_DISABLED - printf("Python %s (free-threading)\n", - (print_version >= 2) ? Py_GetVersion() : PY_VERSION); + printf("Python %s free-threading\n", version); #else - printf("Python %s\n", - (print_version >= 2) ? Py_GetVersion() : PY_VERSION); + printf("Python %s\n", version); #endif return _PyStatus_EXIT(0); }