SF.net SVN: jython:[7254] trunk/jython

[email protected] Mon, 21 Mar 2011 05:01:01 +0000
Newsgroups gmane.comp.lang.jython.cvs
Message-ID <[email protected]>
Revision: 7254
          http://jython.svn.sourceforge.net/jython/?rev=7254&view=rev
Author:   pjenvey
Date:     2011-03-21 05:01:00 +0000 (Mon, 21 Mar 2011)

Log Message:
-----------
more 2.6 exception changes

Modified Paths:
--------------
    trunk/jython/src/org/python/core/Py.java
    trunk/jython/src/org/python/core/PyException.java

Removed Paths:
-------------
    trunk/jython/Lib/test/exception_hierarchy.txt

Deleted: trunk/jython/Lib/test/exception_hierarchy.txt
===================================================================
--- trunk/jython/Lib/test/exception_hierarchy.txt	2011-03-20 19:56:03 UTC (rev 7253)
+++ trunk/jython/Lib/test/exception_hierarchy.txt	2011-03-21 05:01:00 UTC (rev 7254)
@@ -1,49 +0,0 @@
-BaseException
- +-- SystemExit
- +-- KeyboardInterrupt
- +-- GeneratorExit
- +-- Exception
-      +-- StopIteration
-      +-- StandardError
-      |    +-- ArithmeticError
-      |    |    +-- FloatingPointError
-      |    |    +-- OverflowError
-      |    |    +-- ZeroDivisionError
-      |    +-- AssertionError
-      |    +-- AttributeError
-      |    +-- EnvironmentError
-      |    |    +-- IOError
-      |    |    +-- OSError
-      |    |         +-- WindowsError (Windows)
-      |    |         +-- VMSError (VMS)
-      |    +-- EOFError
-      |    +-- ImportError
-      |    +-- LookupError
-      |    |    +-- IndexError
-      |    |    +-- KeyError
-      |    +-- MemoryError
-      |    +-- NameError
-      |    |    +-- UnboundLocalError
-      |    +-- ReferenceError
-      |    +-- RuntimeError
-      |    |    +-- NotImplementedError
-      |    +-- SyntaxError
-      |    |    +-- IndentationError
-      |    |         +-- TabError
-      |    +-- SystemError
-      |    +-- TypeError
-      |    +-- ValueError
-      |         +-- UnicodeError
-      |              +-- UnicodeDecodeError
-      |              +-- UnicodeEncodeError
-      |              +-- UnicodeTranslateError
-      +-- Warning
-           +-- DeprecationWarning
-           +-- PendingDeprecationWarning
-           +-- RuntimeWarning
-           +-- SyntaxWarning
-           +-- UserWarning
-           +-- FutureWarning
-	   +-- ImportWarning
-	   +-- UnicodeWarning
-	   +-- BytesWarning

Modified: trunk/jython/src/org/python/core/Py.java
===================================================================
--- trunk/jython/src/org/python/core/Py.java	2011-03-20 19:56:03 UTC (rev 7253)
+++ trunk/jython/src/org/python/core/Py.java	2011-03-21 05:01:00 UTC (rev 7254)
@@ -353,6 +353,7 @@
     public static PyException MemoryError(String message) {
         return new PyException(Py.MemoryError, message);
     }
+    public static PyObject BufferError;
     public static PyObject ArithmeticError;
     public static PyObject LookupError;
     public static PyObject StandardError;
@@ -767,6 +768,7 @@
         NameError = initExc("NameError", exc, dict);
         UnboundLocalError = initExc("UnboundLocalError", exc, dict);
         AttributeError = initExc("AttributeError", exc, dict);
+
         SyntaxError = initExc("SyntaxError", exc, dict);
         IndentationError = initExc("IndentationError", exc, dict);
         TabError = initExc("TabError", exc, dict);
@@ -787,6 +789,7 @@
         ReferenceError = initExc("ReferenceError", exc, dict);
         SystemError = initExc("SystemError", exc, dict);
         MemoryError = initExc("MemoryError", exc, dict);
+        BufferError = initExc("BufferError", exc, dict);
         Warning = initExc("Warning", exc, dict);
         UserWarning = initExc("UserWarning", exc, dict);
         DeprecationWarning = initExc("DeprecationWarning", exc, dict);

Modified: trunk/jython/src/org/python/core/PyException.java
===================================================================
--- trunk/jython/src/org/python/core/PyException.java	2011-03-20 19:56:03 UTC (rev 7253)
+++ trunk/jython/src/org/python/core/PyException.java	2011-03-21 05:01:00 UTC (rev 7254)
@@ -237,6 +237,13 @@
             return false;
         }
 
+        if (exc instanceof PyString) {
+            Py.DeprecationWarning("catching of string exceptions is deprecated");
+        } else if (Options.py3kwarning && !isPy3kExceptionClass(exc)) {
+            Py.DeprecationWarning("catching classes that don't inherit from BaseException is not "
+                                  + "allowed in 3.x");
+        }
+
         normalize();
         // FIXME, see bug 737978
         //
@@ -279,6 +286,16 @@
         if (obj instanceof PyClass) {
             return true;
         }
+        return isPy3kExceptionClass(obj);
+    }
+
+    /**
+     * Determine whether obj is a Python 3 exception class
+     *
+     * @param obj a PyObject
+     * @return true if an exception
+     */
+    private static boolean isPy3kExceptionClass(PyObject obj) {
         if (!(obj instanceof PyType)) {
             return false;
         }
@@ -286,7 +303,8 @@
         if (type.isSubType(PyBaseException.TYPE)) {
             return true;
         }
-        return type.getProxyType() != null && Throwable.class.isAssignableFrom(type.getProxyType());
+        return type.getProxyType() != null
+                && Throwable.class.isAssignableFrom(type.getProxyType());
     }
 
     /**


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.

------------------------------------------------------------------------------
Colocation vs. Managed Hosting
A question and answer guide to determining the best fit
for your organization - today and in the future.
http://p.sf.net/sfu/internap-sfd2d