summaryrefslogtreecommitdiffstats
path: root/Lib/platform.py
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2024-05-18 20:49:11 (GMT)
committerGitHub <noreply@github.com>2024-05-18 20:49:11 (GMT)
commitec88e9f686a97a7dfc3c2ef28a244e53d313731a (patch)
tree2bc625d27cbe5c9bdfa652786edefc6d27276108 /Lib/platform.py
parent641e59db59a0d1ad712b20948b19eec16a1f9a84 (diff)
downloadcpython-ec88e9f686a97a7dfc3c2ef28a244e53d313731a.zip
cpython-ec88e9f686a97a7dfc3c2ef28a244e53d313731a.tar.gz
cpython-ec88e9f686a97a7dfc3c2ef28a244e53d313731a.tar.bz2
[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 commit c141d4393750c827cbcb3867f0f42997a3bb3528) Co-authored-by: Donghee Na <donghee.na@python.org>
Diffstat (limited to 'Lib/platform.py')
-rwxr-xr-xLib/platform.py24
1 files changed, 15 insertions, 9 deletions
diff --git a/Lib/platform.py b/Lib/platform.py
index ebaba37..5958382 100755
--- a/Lib/platform.py
+++ b/Lib/platform.py
@@ -1153,17 +1153,16 @@ def _sys_version(sys_version=None):
if result is not None:
return result
- sys_version_parser = re.compile(
- r'([\w.+]+)\s*' # "version<space>"
- r'\(#?([^,]+)' # "(#buildno"
- r'(?:,\s*([\w ]*)' # ", builddate"
- r'(?:,\s*([\w :]*))?)?\)\s*' # ", buildtime)<space>"
- r'\[([^\]]+)\]?', re.ASCII) # "[compiler]"
-
if sys.platform.startswith('java'):
# Jython
+ jython_sys_version_parser = re.compile(
+ r'([\w.+]+)\s*' # "version<space>"
+ r'\(#?([^,]+)' # "(#buildno"
+ r'(?:,\s*([\w ]*)' # ", builddate"
+ r'(?:,\s*([\w :]*))?)?\)\s*' # ", buildtime)<space>"
+ 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' %
@@ -1190,7 +1189,14 @@ 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<space>"
+ r'(?:experimental free-threading build\s+)?' # "free-threading-build<space>"
+ r'\(#?([^,]+)' # "(#buildno"
+ r'(?:,\s*([\w ]*)' # ", builddate"
+ r'(?:,\s*([\w :]*))?)?\)\s*' # ", buildtime)<space>"
+ 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' %