Skip to content

Commit fbfeab1

Browse files
committed
fix style issues
1 parent 1ad4ada commit fbfeab1

File tree

4 files changed

+30
-32
lines changed

4 files changed

+30
-32
lines changed

graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/advance/ResourcesTest.java

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2020, 2023, 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
@@ -48,18 +48,12 @@
4848
public class ResourcesTest {
4949
@Test
5050
public void testResourcesAsHome() {
51-
try (Context context = Context.newBuilder("python").
52-
allowExperimentalOptions(true).
53-
option("python.PythonHome", "/path/that/does/not/exist").
54-
build()) {
51+
try (Context context = Context.newBuilder("python").allowExperimentalOptions(true).option("python.PythonHome", "/path/that/does/not/exist").build()) {
5552
String foundHome = context.eval("python", "__graalpython__.home").asString();
5653
assertTrue(foundHome, foundHome.contains("python/python-home"));
5754
}
5855

59-
try (Context context = Context.newBuilder("python").
60-
allowExperimentalOptions(true).
61-
option("python.PythonHome", "").
62-
build()) {
56+
try (Context context = Context.newBuilder("python").allowExperimentalOptions(true).option("python.PythonHome", "").build()) {
6357
String foundHome = context.eval("python", "__graalpython__.home").asString();
6458
assertTrue(foundHome, !foundHome.contains("graalpython"));
6559
}

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

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -216,20 +216,21 @@ private static Class<PythonResource> getPythonResourceClass() {
216216

217217
PYTHON_RESOURCE_CLASS = getPythonResourceClass();
218218
try (InputStream is = PythonLanguage.class.getResourceAsStream("/graalpy_versions")) {
219-
if (MAJOR != is.read()) {
220-
throw new RuntimeException("suite.py version info does not match PythonLanguage#MAJOR");
219+
int ch;
220+
if (MAJOR != (ch = is.read())) {
221+
throw new RuntimeException("suite.py version info does not match PythonLanguage#MAJOR: " + ch);
221222
}
222-
if (MINOR != is.read()) {
223-
throw new RuntimeException("suite.py version info does not match PythonLanguage#MINOR");
223+
if (MINOR != (ch = is.read())) {
224+
throw new RuntimeException("suite.py version info does not match PythonLanguage#MINOR: " + ch);
224225
}
225-
if (MICRO != is.read()) {
226-
throw new RuntimeException("suite.py version info does not match PythonLanguage#MICRO");
226+
if (MICRO != (ch = is.read())) {
227+
throw new RuntimeException("suite.py version info does not match PythonLanguage#MICRO: " + ch);
227228
}
228-
if (GRAALVM_MAJOR != is.read()) {
229-
throw new RuntimeException("suite.py version info does not match PythonLanguage#GRAALVM_MAJOR");
229+
if (GRAALVM_MAJOR != (ch = is.read())) {
230+
throw new RuntimeException("suite.py version info does not match PythonLanguage#GRAALVM_MAJOR: " + ch);
230231
}
231-
if (GRAALVM_MINOR != is.read()) {
232-
throw new RuntimeException("suite.py version info does not match PythonLanguage#GRAALVM_MINOR");
232+
if (GRAALVM_MINOR != (ch = is.read())) {
233+
throw new RuntimeException("suite.py version info does not match PythonLanguage#GRAALVM_MINOR: " + ch);
233234
}
234235
} catch (IOException e) {
235236
throw new RuntimeException(e);

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/lzma/LZMAObject.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2021, 2023, 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

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/PythonContext.java

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1721,18 +1721,20 @@ public void initializeHomeAndPrefixPaths(Env newEnv, String languageHome) {
17211721
home = null;
17221722
}
17231723

1724-
Supplier<?>[] homeCandidates = new Supplier<?>[] {
1725-
() -> { return home; },
1726-
() -> {
1727-
if (PythonLanguage.PYTHON_RESOURCE_CLASS != null) {
1728-
try {
1729-
return newEnv.getInternalResource(PythonLanguage.PYTHON_RESOURCE_CLASS).getAbsoluteFile();
1730-
} catch (IOException e) {
1731-
// fall through
1732-
}
1733-
}
1734-
return null;
1735-
}
1724+
Supplier<?>[] homeCandidates = new Supplier<?>[]{
1725+
() -> {
1726+
return home;
1727+
},
1728+
() -> {
1729+
if (PythonLanguage.PYTHON_RESOURCE_CLASS != null) {
1730+
try {
1731+
return newEnv.getInternalResource(PythonLanguage.PYTHON_RESOURCE_CLASS).getAbsoluteFile();
1732+
} catch (IOException e) {
1733+
// fall through
1734+
}
1735+
}
1736+
return null;
1737+
}
17361738
};
17371739
for (Supplier<?> homeCandidateSupplier : homeCandidates) {
17381740
final TruffleFile homeCandidate = (TruffleFile) homeCandidateSupplier.get();
@@ -1832,6 +1834,7 @@ public void initializeHomeAndPrefixPaths(Env newEnv, String languageHome) {
18321834
if (sysPrefix.isEmpty()) {
18331835
sysPrefix = T_DOT;
18341836
}
1837+
langHome = toTruffleStringUncached(base.relativize(newEnv.getInternalTruffleFile(langHome.toJavaStringUncached())).getPath());
18351838
coreHome = toTruffleStringUncached(base.relativize(newEnv.getInternalTruffleFile(coreHome.toJavaStringUncached())).getPath());
18361839
stdLibHome = toTruffleStringUncached(base.relativize(newEnv.getInternalTruffleFile(stdLibHome.toJavaStringUncached())).getPath());
18371840
capiHome = toTruffleStringUncached(base.relativize(newEnv.getInternalTruffleFile(capiHome.toJavaStringUncached())).getPath());

0 commit comments

Comments
 (0)