[pypy-svn] r56281 - in pypy/branch/2.5-features/pypy: interpreter lib

bgola at codespeak.net bgola at codespeak.net
Fri Jul 4 01:03:09 CEST 2008


Author: bgola
Date: Fri Jul  4 01:03:08 2008
New Revision: 56281

Modified:
   pypy/branch/2.5-features/pypy/interpreter/error.py
   pypy/branch/2.5-features/pypy/lib/_exceptions.py
Log:
PEP 352, BaseException...

Modified: pypy/branch/2.5-features/pypy/interpreter/error.py
==============================================================================
--- pypy/branch/2.5-features/pypy/interpreter/error.py	(original)
+++ pypy/branch/2.5-features/pypy/interpreter/error.py	Fri Jul  4 01:03:08 2008
@@ -175,8 +175,8 @@
 
         elif space.full_exceptions and space.is_w(space.type(w_type),
                                                   space.w_str):
-            # XXX warn -- deprecated
-            pass
+            space.warn("raising a string exception is deprecated", 
+                       space.w_DeprecationWarning)
         else:
 
             # raise X: we assume that X is an already-built instance

Modified: pypy/branch/2.5-features/pypy/lib/_exceptions.py
==============================================================================
--- pypy/branch/2.5-features/pypy/lib/_exceptions.py	(original)
+++ pypy/branch/2.5-features/pypy/lib/_exceptions.py	Fri Jul  4 01:03:08 2008
@@ -19,77 +19,62 @@
 recommended that user defined class based exceptions be derived from the
 `Exception' class, although this is currently not enforced.
 
-Exception
- |
+BaseException
  +-- SystemExit
- +-- StopIteration
- +-- StandardError
- |    |
- |    +-- KeyboardInterrupt
- |    +-- ImportError
- |    +-- EnvironmentError
- |    |    |
- |    |    +-- IOError
- |    |    +-- OSError
- |    |         |
- |    |         +-- WindowsError
- |    |         +-- VMSError
- |    |
- |    +-- EOFError
- |    +-- RuntimeError
- |    |    |
- |    |    +-- NotImplementedError
- |    |
- |    +-- NameError
- |    |    |
- |    |    +-- UnboundLocalError
- |    |
- |    +-- AttributeError
- |    +-- SyntaxError
- |    |    |
- |    |    +-- IndentationError
- |    |         |
- |    |         +-- TabError
- |    |
- |    +-- TypeError
- |    +-- AssertionError
- |    +-- LookupError
- |    |    |
- |    |    +-- IndexError
- |    |    +-- KeyError
- |    |
- |    +-- ArithmeticError
- |    |    |
- |    |    +-- OverflowError
- |    |    +-- ZeroDivisionError
- |    |    +-- FloatingPointError
- |    |
- |    +-- ValueError
- |    |    |
- |    |    +-- UnicodeError
- |    |        |
- |    |        +-- UnicodeEncodeError
- |    |        +-- UnicodeDecodeError
- |    |        +-- UnicodeTranslateError
- |    |
- |    +-- ReferenceError
- |    +-- SystemError
- |    +-- MemoryError
- |
- +---Warning
-      |
-      +-- UserWarning
-      +-- DeprecationWarning
-      +-- PendingDeprecationWarning
-      +-- SyntaxWarning
-      +-- OverflowWarning
-      +-- RuntimeWarning
-      +-- FutureWarning
-      +-- UnicodeWarning
-      +-- ImportWarning"""
-
-class Exception:
-    """Common base class for all exceptions."""
+ +-- KeyboardInterrupt
+ +-- Exception
+      +-- GeneratorExit
+      +-- 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
+"""
+
+class BaseException(object):
+    """Superclass representing the base of the exception hierarchy.
+
+    The __getitem__ method is provided for backwards-compatibility
+    and will be deprecated at some point. 
+    """
 
     def __getitem__(self, idx):
         return self.args[idx]
@@ -107,6 +92,17 @@
         else:
             return str(args)
 
+    def __repr__(self):
+        if self.args:
+            func_args = repr(self.args)
+        else:
+            func_args = "()"
+        return self.__class__.__name__ + func_args
+
+
+class Exception(BaseException):
+    """Common base class for all non-exit exceptions."""
+
 class StandardError(Exception):
     """Base class for all standard Python exceptions."""
 
@@ -293,7 +289,7 @@
 class FutureWarning(Warning):
     """Base class for warnings about constructs that will change semantically in the future."""
 
-class SystemExit(Exception):
+class SystemExit(BaseException):
     """Request to exit from the interpreter."""
 
     def __init__(self, *args):
@@ -376,7 +372,7 @@
 class RuntimeWarning(Warning):
     """Base class for warnings about dubious runtime behavior."""
 
-class KeyboardInterrupt(StandardError):
+class KeyboardInterrupt(BaseException):
     """Program interrupted by user."""
 
 class UserWarning(Warning):



More information about the Pypy-commit mailing list