Fixing exception handling to support Jython