graalpython icon indicating copy to clipboard operation
graalpython copied to clipboard

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

Open timfel opened this issue 3 years ago • 0 comments

        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()

timfel avatar Nov 24 '22 16:11 timfel