From dd95b0ecd5f6b557aa258fe75026d8c9ed3d694b Mon Sep 17 00:00:00 2001 From: Donghee Na Date: Fri, 17 May 2024 19:45:58 -0400 Subject: [PATCH 01/13] gh-119132: Update buildinfo to identify free-threaded or not. --- .../Build/2024-05-17-19-53-27.gh-issue-119132.wepPgM.rst | 2 ++ Modules/getbuildinfo.c | 9 +++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 Misc/NEWS.d/next/Build/2024-05-17-19-53-27.gh-issue-119132.wepPgM.rst diff --git a/Misc/NEWS.d/next/Build/2024-05-17-19-53-27.gh-issue-119132.wepPgM.rst b/Misc/NEWS.d/next/Build/2024-05-17-19-53-27.gh-issue-119132.wepPgM.rst new file mode 100644 index 00000000000000..7fb178ef27be31 --- /dev/null +++ b/Misc/NEWS.d/next/Build/2024-05-17-19-53-27.gh-issue-119132.wepPgM.rst @@ -0,0 +1,2 @@ +Add build information to identify whether the build is default build or +free-threading build. Patch By Donghee Na. diff --git a/Modules/getbuildinfo.c b/Modules/getbuildinfo.c index 8d553d106c6ab5..bb95fec2c74383 100644 --- a/Modules/getbuildinfo.c +++ b/Modules/getbuildinfo.c @@ -51,12 +51,17 @@ Py_GetBuildInfo(void) const char *revision = _Py_gitversion(); const char *sep = *revision ? ":" : ""; const char *gitid = _Py_gitidentifier(); +#ifdef Py_GIL_DISABLED + const char *build = "free-threading"; +#else + const char *build = "default"; +#endif if (!(*gitid)) { gitid = "main"; } PyOS_snprintf(buildinfo, sizeof(buildinfo), - "%s%s%s, %.20s, %.9s", gitid, sep, revision, - DATE, TIME); + "%s%s%s, %.20s, %.9s, %s", gitid, sep, revision, + DATE, TIME, build); return buildinfo; } From 04f5a799a5b77d4319a94e008a2fc7ba3f599d37 Mon Sep 17 00:00:00 2001 From: Donghee Na Date: Sat, 18 May 2024 04:38:44 -0400 Subject: [PATCH 02/13] Update test --- Lib/platform.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Lib/platform.py b/Lib/platform.py index ebaba37563120e..7d9b517ce226f1 100755 --- a/Lib/platform.py +++ b/Lib/platform.py @@ -1154,11 +1154,12 @@ def _sys_version(sys_version=None): return result sys_version_parser = re.compile( - r'([\w.+]+)\s*' # "version" - r'\(#?([^,]+)' # "(#buildno" - r'(?:,\s*([\w ]*)' # ", builddate" - r'(?:,\s*([\w :]*))?)?\)\s*' # ", buildtime)" - r'\[([^\]]+)\]?', re.ASCII) # "[compiler]" + r'([\w.+]+)\s*' # "version" + r'\(#?([^,]+)' # "(#buildno" + r'(?:,\s*([\w ]*)' # ", buildate" + r'(?:,\s*([\w :]*))?)' # ", buildtime" + r'(?:,\s*(free-threading|default))?\)\s*' # ",'free-threading'|'default)'" + r'\[([^\]]+)\]?', re.ASCII) #"[compiler]" if sys.platform.startswith('java'): # Jython @@ -1195,7 +1196,7 @@ def _sys_version(sys_version=None): raise ValueError( 'failed to parse CPython sys.version: %s' % repr(sys_version)) - version, buildno, builddate, buildtime, compiler = \ + version, buildno, builddate, buildtime, _, compiler = \ match.groups() name = 'CPython' if builddate is None: From 5034205aa7665cfe4a467a4b230c0b05520b1b38 Mon Sep 17 00:00:00 2001 From: Donghee Na Date: Sat, 18 May 2024 04:50:37 -0400 Subject: [PATCH 03/13] Only for free-threading --- Lib/platform.py | 2 +- Modules/getbuildinfo.c | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Lib/platform.py b/Lib/platform.py index 7d9b517ce226f1..650952976df6ee 100755 --- a/Lib/platform.py +++ b/Lib/platform.py @@ -1158,7 +1158,7 @@ def _sys_version(sys_version=None): r'\(#?([^,]+)' # "(#buildno" r'(?:,\s*([\w ]*)' # ", buildate" r'(?:,\s*([\w :]*))?)' # ", buildtime" - r'(?:,\s*(free-threading|default))?\)\s*' # ",'free-threading'|'default)'" + r'(?:,\s*(free-threading))?\)*\s*' # ",'free-threading')'" r'\[([^\]]+)\]?', re.ASCII) #"[compiler]" if sys.platform.startswith('java'): diff --git a/Modules/getbuildinfo.c b/Modules/getbuildinfo.c index bb95fec2c74383..661a0b691b2282 100644 --- a/Modules/getbuildinfo.c +++ b/Modules/getbuildinfo.c @@ -51,17 +51,19 @@ Py_GetBuildInfo(void) const char *revision = _Py_gitversion(); const char *sep = *revision ? ":" : ""; const char *gitid = _Py_gitidentifier(); -#ifdef Py_GIL_DISABLED - const char *build = "free-threading"; -#else - const char *build = "default"; -#endif if (!(*gitid)) { gitid = "main"; } +#ifdef Py_GIL_DISABLED + const char *build = "free-threading"; PyOS_snprintf(buildinfo, sizeof(buildinfo), "%s%s%s, %.20s, %.9s, %s", gitid, sep, revision, DATE, TIME, build); +#else + PyOS_snprintf(buildinfo, sizeof(buildinfo), + "%s%s%s, %.20s, %.9s", gitid, sep, revision, + DATE, TIME); +#endif return buildinfo; } From f135b42020674de56860a74987ab75e095318290 Mon Sep 17 00:00:00 2001 From: Donghee Na Date: Sat, 18 May 2024 05:23:49 -0400 Subject: [PATCH 04/13] Update Lib/platform.py Co-authored-by: Nice Zombies --- Lib/platform.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Lib/platform.py b/Lib/platform.py index 650952976df6ee..0209a40a6a4288 100755 --- a/Lib/platform.py +++ b/Lib/platform.py @@ -1154,12 +1154,12 @@ def _sys_version(sys_version=None): return result sys_version_parser = re.compile( - r'([\w.+]+)\s*' # "version" - r'\(#?([^,]+)' # "(#buildno" - r'(?:,\s*([\w ]*)' # ", buildate" - r'(?:,\s*([\w :]*))?)' # ", buildtime" - r'(?:,\s*(free-threading))?\)*\s*' # ",'free-threading')'" - r'\[([^\]]+)\]?', re.ASCII) #"[compiler]" + r'([\w.+]+)\s*' # "version" + r'\(#?([^,]+)' # "(#buildno" + r'(?:,\s*([\w ]*)' # ", buildate" + r'(?:,\s*([\w :]*))?)?' # ", buildtime" + r'(?:,\s*(free-threading))?\)*\s*' # ",'free-threading')'" + r'\[([^\]]+)\]?', re.ASCII) #"[compiler]" if sys.platform.startswith('java'): # Jython From 94cbf8d6ca24bf2581f79b9bf0ea75611e10f86b Mon Sep 17 00:00:00 2001 From: Donghee Na Date: Sat, 18 May 2024 05:28:31 -0400 Subject: [PATCH 05/13] Update Lib/platform.py Co-authored-by: Nice Zombies --- Lib/platform.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/platform.py b/Lib/platform.py index 0209a40a6a4288..7ad921efee47f4 100755 --- a/Lib/platform.py +++ b/Lib/platform.py @@ -1156,10 +1156,10 @@ def _sys_version(sys_version=None): sys_version_parser = re.compile( r'([\w.+]+)\s*' # "version" r'\(#?([^,]+)' # "(#buildno" - r'(?:,\s*([\w ]*)' # ", buildate" + r'(?:,\s*([\w ]*)' # ", builddate" r'(?:,\s*([\w :]*))?)?' # ", buildtime" r'(?:,\s*(free-threading))?\)*\s*' # ",'free-threading')'" - r'\[([^\]]+)\]?', re.ASCII) #"[compiler]" + r'\[([^\]]+)\]?', re.ASCII) # "[compiler]" if sys.platform.startswith('java'): # Jython From e2d60ba3ccc52668d0b6eef3920093b6bc8207f5 Mon Sep 17 00:00:00 2001 From: Donghee Na Date: Sat, 18 May 2024 13:41:03 -0400 Subject: [PATCH 06/13] Address code review --- Lib/platform.py | 23 +++++++++++++++---- ...-05-17-19-53-27.gh-issue-119132.wepPgM.rst | 2 +- Modules/getbuildinfo.c | 7 ------ Python/getversion.c | 7 +++++- 4 files changed, 25 insertions(+), 14 deletions(-) diff --git a/Lib/platform.py b/Lib/platform.py index 7ad921efee47f4..6356c475796c35 100755 --- a/Lib/platform.py +++ b/Lib/platform.py @@ -1155,16 +1155,22 @@ def _sys_version(sys_version=None): sys_version_parser = re.compile( r'([\w.+]+)\s*' # "version" + r'(free-threading)?\s*' r'\(#?([^,]+)' # "(#buildno" r'(?:,\s*([\w ]*)' # ", builddate" - r'(?:,\s*([\w :]*))?)?' # ", buildtime" - r'(?:,\s*(free-threading))?\)*\s*' # ",'free-threading')'" + r'(?:,\s*([\w :]*))?)?\)\s*' # ", buildtime)" r'\[([^\]]+)\]?', re.ASCII) # "[compiler]" if sys.platform.startswith('java'): # Jython + jython_sys_version_parser = re.compile( + r'([\w.+]+)\s*' # "version" + r'\(#?([^,]+)' # "(#buildno" + r'(?:,\s*([\w ]*)' # ", builddate" + r'(?:,\s*([\w :]*))?)?\)\s*' # ", buildtime)" + r'\[([^\]]+)\]?', re.ASCII) # "[compiler]" name = 'Jython' - match = sys_version_parser.match(sys_version) + match = jython_sys_version_parser.match(sys_version) if match is None: raise ValueError( 'failed to parse Jython sys.version: %s' % @@ -1191,12 +1197,19 @@ def _sys_version(sys_version=None): else: # CPython - match = sys_version_parser.match(sys_version) + cpython_sys_version_parser = re.compile( + r'([\w.+]+)\s*' # "version" + r'(free-threading)?\s*' + r'\(#?([^,]+)' # "(#buildno" + r'(?:,\s*([\w ]*)' # ", builddate" + r'(?:,\s*([\w :]*))?)?\)\s*' # ", buildtime)" + r'\[([^\]]+)\]?', re.ASCII) # "[compiler]" + match = cpython_sys_version_parser.match(sys_version) if match is None: raise ValueError( 'failed to parse CPython sys.version: %s' % repr(sys_version)) - version, buildno, builddate, buildtime, _, compiler = \ + version, _, buildno, builddate, buildtime, compiler = \ match.groups() name = 'CPython' if builddate is None: diff --git a/Misc/NEWS.d/next/Build/2024-05-17-19-53-27.gh-issue-119132.wepPgM.rst b/Misc/NEWS.d/next/Build/2024-05-17-19-53-27.gh-issue-119132.wepPgM.rst index 7fb178ef27be31..e39687e26e11fd 100644 --- a/Misc/NEWS.d/next/Build/2024-05-17-19-53-27.gh-issue-119132.wepPgM.rst +++ b/Misc/NEWS.d/next/Build/2024-05-17-19-53-27.gh-issue-119132.wepPgM.rst @@ -1,2 +1,2 @@ -Add build information to identify whether the build is default build or +Update data:`sys.version` to identify whether the build is default build or free-threading build. Patch By Donghee Na. diff --git a/Modules/getbuildinfo.c b/Modules/getbuildinfo.c index 661a0b691b2282..8d553d106c6ab5 100644 --- a/Modules/getbuildinfo.c +++ b/Modules/getbuildinfo.c @@ -54,16 +54,9 @@ Py_GetBuildInfo(void) if (!(*gitid)) { gitid = "main"; } -#ifdef Py_GIL_DISABLED - const char *build = "free-threading"; - PyOS_snprintf(buildinfo, sizeof(buildinfo), - "%s%s%s, %.20s, %.9s, %s", gitid, sep, revision, - DATE, TIME, build); -#else PyOS_snprintf(buildinfo, sizeof(buildinfo), "%s%s%s, %.20s, %.9s", gitid, sep, revision, DATE, TIME); -#endif return buildinfo; } diff --git a/Python/getversion.c b/Python/getversion.c index 5db836ab4bfd6d..61cb7b1d12d5f1 100644 --- a/Python/getversion.c +++ b/Python/getversion.c @@ -14,7 +14,12 @@ void _Py_InitVersion(void) return; } initialized = 1; - PyOS_snprintf(version, sizeof(version), "%.80s (%.80s) %.80s", +#ifdef Py_GIL_DISABLED + const char *buildinfo_format = "%.80s free-threading (%.80s) %.80s"; +#else + const char *buildinfo_format = "%.80s (%.80s) %.80s"; +#endif + PyOS_snprintf(version, sizeof(version), buildinfo_format, PY_VERSION, Py_GetBuildInfo(), Py_GetCompiler()); } From 4bb1d668616a7a381709c4f2a7c9f17910fcfc73 Mon Sep 17 00:00:00 2001 From: Donghee Na Date: Sat, 18 May 2024 13:42:40 -0400 Subject: [PATCH 07/13] Add comment --- Lib/platform.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/platform.py b/Lib/platform.py index 6356c475796c35..01b1156e12e7e9 100755 --- a/Lib/platform.py +++ b/Lib/platform.py @@ -1199,7 +1199,7 @@ def _sys_version(sys_version=None): # CPython cpython_sys_version_parser = re.compile( r'([\w.+]+)\s*' # "version" - r'(free-threading)?\s*' + r'(free-threading)?\s*' # "free-threading" r'\(#?([^,]+)' # "(#buildno" r'(?:,\s*([\w ]*)' # ", builddate" r'(?:,\s*([\w :]*))?)?\)\s*' # ", buildtime)" From a7e369714654bd085f81e727940ae302209b9638 Mon Sep 17 00:00:00 2001 From: Donghee Na Date: Sat, 18 May 2024 13:44:59 -0400 Subject: [PATCH 08/13] Fix docs --- .../next/Build/2024-05-17-19-53-27.gh-issue-119132.wepPgM.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Build/2024-05-17-19-53-27.gh-issue-119132.wepPgM.rst b/Misc/NEWS.d/next/Build/2024-05-17-19-53-27.gh-issue-119132.wepPgM.rst index e39687e26e11fd..44fe2a1a1f6725 100644 --- a/Misc/NEWS.d/next/Build/2024-05-17-19-53-27.gh-issue-119132.wepPgM.rst +++ b/Misc/NEWS.d/next/Build/2024-05-17-19-53-27.gh-issue-119132.wepPgM.rst @@ -1,2 +1,2 @@ -Update data:`sys.version` to identify whether the build is default build or +Update :data:`sys.version` to identify whether the build is default build or free-threading build. Patch By Donghee Na. From f54cef43da1149b675c0189e4369d9812cfa64f9 Mon Sep 17 00:00:00 2001 From: Donghee Na Date: Sat, 18 May 2024 13:51:53 -0400 Subject: [PATCH 09/13] nit --- Lib/platform.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/Lib/platform.py b/Lib/platform.py index 01b1156e12e7e9..b6128a908a8895 100755 --- a/Lib/platform.py +++ b/Lib/platform.py @@ -1153,14 +1153,6 @@ def _sys_version(sys_version=None): if result is not None: return result - sys_version_parser = re.compile( - r'([\w.+]+)\s*' # "version" - r'(free-threading)?\s*' - r'\(#?([^,]+)' # "(#buildno" - r'(?:,\s*([\w ]*)' # ", builddate" - r'(?:,\s*([\w :]*))?)?\)\s*' # ", buildtime)" - r'\[([^\]]+)\]?', re.ASCII) # "[compiler]" - if sys.platform.startswith('java'): # Jython jython_sys_version_parser = re.compile( From e0b33700ef63ef1ba6de7c42a1ccc0cfbb5b9959 Mon Sep 17 00:00:00 2001 From: Donghee Na Date: Sat, 18 May 2024 13:58:40 -0400 Subject: [PATCH 10/13] Address code review --- Lib/platform.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/platform.py b/Lib/platform.py index b6128a908a8895..610567b5d3b9b3 100755 --- a/Lib/platform.py +++ b/Lib/platform.py @@ -1191,7 +1191,7 @@ def _sys_version(sys_version=None): # CPython cpython_sys_version_parser = re.compile( r'([\w.+]+)\s*' # "version" - r'(free-threading)?\s*' # "free-threading" + r'(?:free-threading)?\s*' # "free-threading" r'\(#?([^,]+)' # "(#buildno" r'(?:,\s*([\w ]*)' # ", builddate" r'(?:,\s*([\w :]*))?)?\)\s*' # ", buildtime)" @@ -1201,7 +1201,7 @@ def _sys_version(sys_version=None): raise ValueError( 'failed to parse CPython sys.version: %s' % repr(sys_version)) - version, _, buildno, builddate, buildtime, compiler = \ + version, buildno, builddate, buildtime, compiler = \ match.groups() name = 'CPython' if builddate is None: From c3fd105575c98fb1da5784af99b829a5948c4420 Mon Sep 17 00:00:00 2001 From: Donghee Na Date: Sat, 18 May 2024 14:08:59 -0400 Subject: [PATCH 11/13] Address code review --- Lib/platform.py | 2 +- Python/getversion.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/platform.py b/Lib/platform.py index 610567b5d3b9b3..ee187bac3530ec 100755 --- a/Lib/platform.py +++ b/Lib/platform.py @@ -1191,7 +1191,7 @@ def _sys_version(sys_version=None): # CPython cpython_sys_version_parser = re.compile( r'([\w.+]+)\s*' # "version" - r'(?:free-threading)?\s*' # "free-threading" + r'(?:experimental free-threading build)?\s*' # "free-threading-build" r'\(#?([^,]+)' # "(#buildno" r'(?:,\s*([\w ]*)' # ", builddate" r'(?:,\s*([\w :]*))?)?\)\s*' # ", buildtime)" diff --git a/Python/getversion.c b/Python/getversion.c index 61cb7b1d12d5f1..f25045e50d56ac 100644 --- a/Python/getversion.c +++ b/Python/getversion.c @@ -15,7 +15,7 @@ void _Py_InitVersion(void) } initialized = 1; #ifdef Py_GIL_DISABLED - const char *buildinfo_format = "%.80s free-threading (%.80s) %.80s"; + const char *buildinfo_format = "%.80s experimental free-threading build (%.80s) %.80s"; #else const char *buildinfo_format = "%.80s (%.80s) %.80s"; #endif From a29a17df91354ec8f551cee6dd6fcbf389ba9370 Mon Sep 17 00:00:00 2001 From: Donghee Na Date: Sat, 18 May 2024 15:02:28 -0400 Subject: [PATCH 12/13] Increase the buffer --- Python/getversion.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Python/getversion.c b/Python/getversion.c index f25045e50d56ac..226b2f999a6bfd 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[300]; void _Py_InitVersion(void) { From 267a0fd951dbf298814aeb595bcc38a1a7d2e10c Mon Sep 17 00:00:00 2001 From: Donghee Na Date: Sat, 18 May 2024 15:17:45 -0400 Subject: [PATCH 13/13] Update Lib/platform.py Co-authored-by: Victor Stinner --- Lib/platform.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/platform.py b/Lib/platform.py index ee187bac3530ec..5958382276e79c 100755 --- a/Lib/platform.py +++ b/Lib/platform.py @@ -1191,7 +1191,7 @@ def _sys_version(sys_version=None): # CPython cpython_sys_version_parser = re.compile( r'([\w.+]+)\s*' # "version" - r'(?:experimental free-threading build)?\s*' # "free-threading-build" + r'(?:experimental free-threading build\s+)?' # "free-threading-build" r'\(#?([^,]+)' # "(#buildno" r'(?:,\s*([\w ]*)' # ", builddate" r'(?:,\s*([\w :]*))?)?\)\s*' # ", buildtime)" 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