Skip to content

Commit 4cb6c83

Browse files
committed
fail with a better error message when core files are not available during context initialization
1 parent 2eeb0d9 commit 4cb6c83

File tree

1 file changed

+7
-2
lines changed
  • graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins

1 file changed

+7
-2
lines changed

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import java.util.Map.Entry;
4242
import java.util.ServiceLoader;
4343
import java.util.function.Supplier;
44+
import java.util.logging.Level;
4445

4546
import org.graalvm.nativeimage.ImageInfo;
4647

@@ -652,10 +653,14 @@ private Source getSource(String basename, String prefix) {
652653
Env env = ctxt.getEnv();
653654
TruffleFile file = env.getTruffleFile(prefix + suffix);
654655
try {
655-
return getLanguage().newSource(ctxt, file, basename);
656+
if (file.exists()) {
657+
return getLanguage().newSource(ctxt, file, basename);
658+
}
656659
} catch (SecurityException | IOException t) {
657-
throw new RuntimeException("Could not read core library from " + file);
660+
// fall through;
658661
}
662+
PythonLanguage.getLogger().log(Level.SEVERE, "Startup failed, could not read core library from " + file + ". Maybe you need to set python.CoreHome and python.StdLibHome.");
663+
throw new RuntimeException();
659664
}
660665
}
661666

0 commit comments

Comments
 (0)