Skip to content

Commit ed70c57

Browse files
committed
[GR-56295] Fix: allow GraalVM versions with more than 3 components.
PullRequest: graalpython/3505
2 parents 1d0bbc9 + 035382e commit ed70c57

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

graalpython/com.oracle.graal.python.resources/src/com/oracle/graal/python/resources/PythonResource.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* The Universal Permissive License (UPL), Version 1.0
@@ -69,6 +69,7 @@ public final class PythonResource implements InternalResource {
6969
private static final int VERSION_BASE = '!';
7070

7171
static {
72+
// See static ctor of PythonLanguage
7273
try (InputStream is = PythonResource.class.getResourceAsStream("/graalpy_versions")) {
7374
PYTHON_MAJOR = is.read() - VERSION_BASE;
7475
PYTHON_MINOR = is.read() - VERSION_BASE;

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/PythonLanguage.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,9 @@ public final class PythonLanguage extends TruffleLanguage<PythonContext> {
222222
RELEASE_LEVEL_STRING = tsLiteral("final");
223223
}
224224

225+
// The resource file is built by mx from "graalpy-versions" project using mx substitutions.
226+
// The actual values of the versions are computed by mx helper functions py_version_short,
227+
// graal_version_short, and dev_tag defined in mx_graalpython.py
225228
try (InputStream is = PythonLanguage.class.getResourceAsStream("/graalpy_versions")) {
226229
int ch;
227230
if (MAJOR != (ch = is.read() - VERSION_BASE)) {

mx.graalpython/mx_graalpython.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1833,7 +1833,10 @@ def graal_version_short(variant=None, **kwargs):
18331833
if variant == 'major_minor_nodot':
18341834
return GRAAL_VERSION_MAJ_MIN.replace(".", "")
18351835
elif variant == 'binary':
1836-
return "".join([chr(int(p) + ord(VERSION_BASE)) for p in GRAAL_VERSION.split(".")])
1836+
# PythonLanguage and PythonResource consume this data, and they assume 3 components
1837+
# (although the 3rd is not used), so we cap the list size to 3 although the version
1838+
# may have even more components
1839+
return "".join([chr(int(p) + ord(VERSION_BASE)) for p in GRAAL_VERSION.split(".")[:3]])
18371840
else:
18381841
return GRAAL_VERSION_MAJ_MIN
18391842

0 commit comments

Comments
 (0)