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' %
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' %
#include "patchlevel.h"
static int initialized = 0;
-static char version[250];
+static char version[300];
void _Py_InitVersion(void)
{
return;
}
initialized = 1;
- PyOS_snprintf(version, sizeof(version), "%.80s (%.80s) %.80s",
+#ifdef Py_GIL_DISABLED
+ const char *buildinfo_format = "%.80s experimental free-threading build (%.80s) %.80s";
+#else
+ const char *buildinfo_format = "%.80s (%.80s) %.80s";
+#endif
+ PyOS_snprintf(version, sizeof(version), buildinfo_format,
PY_VERSION, Py_GetBuildInfo(), Py_GetCompiler());
}