Skip to content

Commit c07ef1a

Browse files
committed
Take Copilot suggestion.
Make it look like the `Python2Interpreter`.
1 parent a386908 commit c07ef1a

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

com.ibm.wala.cast.python.jython3/source/com/ibm/wala/cast/python/util/Python3Interpreter.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.ibm.wala.cast.python.util;
22

3+
import org.python.core.PyException;
34
import org.python.core.PyObject;
45
import org.python.core.PySystemState;
56
import org.python.util.PythonInterpreter;
@@ -17,11 +18,15 @@ public static PythonInterpreter getInterp() {
1718
}
1819

1920
public Integer evalAsInteger(String expr) {
20-
PyObject val = getInterp().eval(expr);
21-
if (val.isInteger()) {
22-
return val.asInt();
23-
} else {
24-
return null;
21+
try {
22+
PyObject val = getInterp().eval(expr);
23+
if (val.isInteger()) {
24+
return val.asInt();
25+
}
26+
} catch (PyException e) {
27+
2528
}
29+
30+
return null;
2631
}
2732
}

0 commit comments

Comments
 (0)