Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitec88e9f

Browse files
[3.13]gh-119132: Update sys.version to identify free-threaded or not. (gh-119134) (#119153)
gh-119132: Update sys.version to identify free-threaded or not. (gh-119134)(cherry picked from commitc141d43)Co-authored-by: Donghee Na <donghee.na@python.org>
1 parent641e59d commitec88e9f

File tree

3 files changed

+24
-11
lines changed

3 files changed

+24
-11
lines changed

‎Lib/platform.py‎

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,17 +1153,16 @@ def _sys_version(sys_version=None):
11531153
ifresultisnotNone:
11541154
returnresult
11551155

1156-
sys_version_parser=re.compile(
1157-
r'([\w.+]+)\s*'# "version<space>"
1158-
r'\(#?([^,]+)'# "(#buildno"
1159-
r'(?:,\s*([\w ]*)'# ", builddate"
1160-
r'(?:,\s*([\w :]*))?)?\)\s*'# ", buildtime)<space>"
1161-
r'\[([^\]]+)\]?',re.ASCII)# "[compiler]"
1162-
11631156
ifsys.platform.startswith('java'):
11641157
# Jython
1158+
jython_sys_version_parser=re.compile(
1159+
r'([\w.+]+)\s*'# "version<space>"
1160+
r'\(#?([^,]+)'# "(#buildno"
1161+
r'(?:,\s*([\w ]*)'# ", builddate"
1162+
r'(?:,\s*([\w :]*))?)?\)\s*'# ", buildtime)<space>"
1163+
r'\[([^\]]+)\]?',re.ASCII)# "[compiler]"
11651164
name='Jython'
1166-
match=sys_version_parser.match(sys_version)
1165+
match=jython_sys_version_parser.match(sys_version)
11671166
ifmatchisNone:
11681167
raiseValueError(
11691168
'failed to parse Jython sys.version: %s'%
@@ -1190,7 +1189,14 @@ def _sys_version(sys_version=None):
11901189

11911190
else:
11921191
# CPython
1193-
match=sys_version_parser.match(sys_version)
1192+
cpython_sys_version_parser=re.compile(
1193+
r'([\w.+]+)\s*'# "version<space>"
1194+
r'(?:experimental free-threading build\s+)?'# "free-threading-build<space>"
1195+
r'\(#?([^,]+)'# "(#buildno"
1196+
r'(?:,\s*([\w ]*)'# ", builddate"
1197+
r'(?:,\s*([\w :]*))?)?\)\s*'# ", buildtime)<space>"
1198+
r'\[([^\]]+)\]?',re.ASCII)# "[compiler]"
1199+
match=cpython_sys_version_parser.match(sys_version)
11941200
ifmatchisNone:
11951201
raiseValueError(
11961202
'failed to parse CPython sys.version: %s'%
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Update:data:`sys.version` to identify whether the build is default build or
2+
free-threading build. Patch By Donghee Na.

‎Python/getversion.c‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,20 @@
66
#include"patchlevel.h"
77

88
staticintinitialized=0;
9-
staticcharversion[250];
9+
staticcharversion[300];
1010

1111
void_Py_InitVersion(void)
1212
{
1313
if (initialized) {
1414
return;
1515
}
1616
initialized=1;
17-
PyOS_snprintf(version,sizeof(version),"%.80s (%.80s) %.80s",
17+
#ifdefPy_GIL_DISABLED
18+
constchar*buildinfo_format="%.80s experimental free-threading build (%.80s) %.80s";
19+
#else
20+
constchar*buildinfo_format="%.80s (%.80s) %.80s";
21+
#endif
22+
PyOS_snprintf(version,sizeof(version),buildinfo_format,
1823
PY_VERSION,Py_GetBuildInfo(),Py_GetCompiler());
1924
}
2025

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp