From: <cg...@us...> - 2008-12-06 05:18:11
|
Revision: 5711 http://jython.svn.sourceforge.net/jython/?rev=5711&view=rev Author: cgroves Date: 2008-12-06 05:18:08 +0000 (Sat, 06 Dec 2008) Log Message: ----------- Identify Java exceptions as exceptions Modified Paths: -------------- branches/newstyle-java-types/src/org/python/core/PyException.java Modified: branches/newstyle-java-types/src/org/python/core/PyException.java =================================================================== --- branches/newstyle-java-types/src/org/python/core/PyException.java 2008-12-06 04:23:45 UTC (rev 5710) +++ branches/newstyle-java-types/src/org/python/core/PyException.java 2008-12-06 05:18:08 UTC (rev 5711) @@ -199,8 +199,17 @@ * @return true if an exception */ public static boolean isExceptionClass(PyObject obj) { - return obj instanceof PyClass - || (obj instanceof PyType && ((PyType)obj).isSubType((PyType)Py.BaseException)); + if (obj instanceof PyClass) { + return true; + } + if (!(obj instanceof PyType)) { + return false; + } + PyType type = ((PyType)obj); + if(type.isSubType((PyType)Py.BaseException)){ + return true; + } + return type.getProxyType() != null && Throwable.class.isAssignableFrom(type.getProxyType()); } /** @@ -210,7 +219,8 @@ * @return true if an exception instance */ public static boolean isExceptionInstance(PyObject obj) { - return obj instanceof PyInstance || obj instanceof PyBaseException; + return obj instanceof PyInstance || obj instanceof PyBaseException + || obj.getJavaProxy() instanceof Throwable; } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |