oracle / graalpython

A Python 3 implementation built on GraalVM
Other
1.2k stars 104 forks source link

Python should not unconditionally print java exceptions, and not to stdout #298

Open timfel opened 1 year ago

timfel commented 1 year ago
        Context ctx = Context.newBuilder("python").allowAllAccess(true).build();
        try {
            ctx.eval("python", "import java; java.math.BigInteger.ONE.divide(java.math.BigInteger.ZERO)");
        } catch (Exception e) {
        }

This prints the zero division exception from Java via https://github.com/oracle/graalpython/blob/master/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/exception/TopLevelExceptionHandler.java#L217. This should be guarded by something like https://github.com/oracle/graalpython/blob/master/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/exception/TopLevelExceptionHandler.java#L182 and then also print to getContext().getEnv().err()