Skip to content

Commit 9c47652

Browse files
committed
[GR-14247] Remove loading python source from URL (Jar)
PullRequest: graalpython/422
2 parents 09d111e + 54d5204 commit 9c47652

File tree

2 files changed

+9
-41
lines changed

2 files changed

+9
-41
lines changed

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

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
package com.oracle.graal.python;
2727

2828
import java.io.IOException;
29-
import java.net.URL;
3029
import java.text.MessageFormat;
3130
import java.util.ArrayList;
3231
import java.util.concurrent.ConcurrentHashMap;
@@ -520,20 +519,6 @@ public Source newSource(PythonContext ctxt, TruffleFile src, String name) throws
520519
}
521520
}
522521

523-
public Source newSource(PythonContext ctxt, URL url, String name) throws IOException {
524-
try {
525-
return cachedSources.computeIfAbsent(url, t -> {
526-
try {
527-
return newSource(ctxt, Source.newBuilder(ID, url).name(name));
528-
} catch (IOException e) {
529-
throw new RuntimeException(e);
530-
}
531-
});
532-
} catch (RuntimeException e) {
533-
throw (IOException) e.getCause();
534-
}
535-
}
536-
537522
private static Source newSource(PythonContext ctxt, SourceBuilder srcBuilder) throws IOException {
538523
boolean coreIsInitialized = ctxt.getCore().isInitialized();
539524
boolean internal = !coreIsInitialized && !PythonOptions.getOption(ctxt, PythonOptions.ExposeInternalSources);

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/Python3Core.java

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@
3131

3232
import java.io.IOException;
3333
import java.math.BigInteger;
34-
import java.net.MalformedURLException;
35-
import java.net.URL;
3634
import java.util.ArrayList;
3735
import java.util.Arrays;
3836
import java.util.HashMap;
@@ -598,34 +596,19 @@ private void addBuiltinsTo(PythonObject obj, PythonBuiltins builtinsForObj) {
598596

599597
@TruffleBoundary
600598
private Source getSource(String basename, String prefix) {
601-
URL url = null;
602-
try {
603-
url = new URL(prefix);
604-
} catch (MalformedURLException e) {
605-
// pass
606-
}
607599
String suffix = FILE_SEPARATOR + basename + ".py";
608600
PythonContext ctxt = getContext();
609-
if (url != null) {
610-
// This path is hit when we load the core library e.g. from a Jar file
611-
try {
612-
return getLanguage().newSource(ctxt, new URL(url + suffix), basename);
613-
} catch (IOException e) {
614-
throw new RuntimeException("Could not read core library from " + url);
615-
}
616-
} else {
617-
Env env = ctxt.getEnv();
618-
TruffleFile file = env.getTruffleFile(prefix + suffix);
619-
try {
620-
if (file.exists()) {
621-
return getLanguage().newSource(ctxt, file, basename);
622-
}
623-
} catch (SecurityException | IOException t) {
624-
// fall through;
601+
Env env = ctxt.getEnv();
602+
TruffleFile file = env.getTruffleFile(prefix + suffix);
603+
try {
604+
if (file.exists()) {
605+
return getLanguage().newSource(ctxt, file, basename);
625606
}
626-
PythonLanguage.getLogger().log(Level.SEVERE, "Startup failed, could not read core library from " + file + ". Maybe you need to set python.CoreHome and python.StdLibHome.");
627-
throw new RuntimeException();
607+
} catch (SecurityException | IOException t) {
608+
// fall through;
628609
}
610+
PythonLanguage.getLogger().log(Level.SEVERE, "Startup failed, could not read core library from " + file + ". Maybe you need to set python.CoreHome and python.StdLibHome.");
611+
throw new RuntimeException();
629612
}
630613

631614
private void loadFile(String s, String prefix) {

0 commit comments

Comments
 (0)