Skip to content

Commit 08120ff

Browse files
committed
[GR-14247] Remove loading python source from URL (Jar)
1 parent 7a651ba commit 08120ff

File tree

2 files changed

+9
-38
lines changed

2 files changed

+9
-38
lines changed

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

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -520,20 +520,6 @@ public Source newSource(PythonContext ctxt, TruffleFile src, String name) throws
520520
}
521521
}
522522

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-
537523
private static Source newSource(PythonContext ctxt, SourceBuilder srcBuilder) throws IOException {
538524
boolean coreIsInitialized = ctxt.getCore().isInitialized();
539525
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 & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -598,34 +598,19 @@ private void addBuiltinsTo(PythonObject obj, PythonBuiltins builtinsForObj) {
598598

599599
@TruffleBoundary
600600
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-
}
607601
String suffix = FILE_SEPARATOR + basename + ".py";
608602
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;
603+
Env env = ctxt.getEnv();
604+
TruffleFile file = env.getTruffleFile(prefix + suffix);
605+
try {
606+
if (file.exists()) {
607+
return getLanguage().newSource(ctxt, file, basename);
625608
}
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();
609+
} catch (SecurityException | IOException t) {
610+
// fall through;
628611
}
612+
PythonLanguage.getLogger().log(Level.SEVERE, "Startup failed, could not read core library from " + file + ". Maybe you need to set python.CoreHome and python.StdLibHome.");
613+
throw new RuntimeException();
629614
}
630615

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

0 commit comments

Comments
 (0)