Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Lib/platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -1167,7 +1167,7 @@ def _sys_version(sys_version=None):
r'\(#?([^,]+)' # "(#buildno"
r'(?:,\s*([\w ]*)' # ", builddate"
r'(?:,\s*([\w :]*))?)?\)\s*' # ", buildtime)<space>"
r'\[([^\]]+)\]?', re.ASCII) # "[compiler]"
r'(?:\[([^\]]+)\])?', re.ASCII) # "[compiler]"
match = cpython_sys_version_parser.match(sys_version)
if match is None:
raise ValueError(
Expand All @@ -1180,6 +1180,8 @@ def _sys_version(sys_version=None):
builddate = ''
elif buildtime:
builddate = builddate + ' ' + buildtime
if compiler is None:
compiler = ''

if hasattr(sys, '_git'):
_, branch, revision = sys._git
Expand Down
6 changes: 6 additions & 0 deletions Lib/test/test_platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,12 @@ def test_sys_version(self):
('CPython', '3.10.8', '', '',
('tags/v3.10.8:aaaf517424', 'Feb 14 2023 16:28:12'), 'GCC 9.4.0'),

("3.15.0 (main, Nov 22 2026, 15:47:50) ",
None, "linux")
:
('CPython', '3.15.0', '', '',
('main', 'Nov 22 2026 15:47:50'), ''),

("2.5 (trunk:6107, Mar 26 2009, 13:02:18) \n[Java HotSpot(TM) Client VM (\"Apple Computer, Inc.\")]",
('Jython', 'trunk', '6107'), "java1.5.0_16")
:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix :mod:`platform` to accept :data:`sys.version` strings without compiler
identification, returning an empty string from :func:`platform.python_compiler`.
Loading