[pypy-svn] r78027 - in pypy/branch/fast-forward: lib-python pypy/interpreter pypy/interpreter/test

trundle at codespeak.net trundle at codespeak.net
Sun Oct 17 01:29:32 CEST 2010


Author: trundle
Date: Sun Oct 17 01:29:28 2010
New Revision: 78027

Modified:
   pypy/branch/fast-forward/lib-python/TODO
   pypy/branch/fast-forward/pypy/interpreter/error.py
   pypy/branch/fast-forward/pypy/interpreter/test/test_generator.py
Log:
Raising a string as exception is not allowed anymore.


Modified: pypy/branch/fast-forward/lib-python/TODO
==============================================================================
--- pypy/branch/fast-forward/lib-python/TODO	(original)
+++ pypy/branch/fast-forward/lib-python/TODO	Sun Oct 17 01:29:28 2010
@@ -34,10 +34,8 @@
 - Ast objects should be picklable, see in pypy/module/_ast/test/test_ast.py:
   test_pickle()
 
-- "exceptions must be old-style classes or derived from BaseException, not str"
-  in the 'raise' statement and generator.throw(), catching a string
-  should emit a DeprecationWarning ("catching of string exceptions is
-  deprecated")
+- catching a string should emit a DeprecationWarning ("catching of
+  string exceptions is deprecated")
 
 - missing builtin: memoryview
 

Modified: pypy/branch/fast-forward/pypy/interpreter/error.py
==============================================================================
--- pypy/branch/fast-forward/pypy/interpreter/error.py	(original)
+++ pypy/branch/fast-forward/pypy/interpreter/error.py	Sun Oct 17 01:29:28 2010
@@ -202,19 +202,14 @@
                         w_value = space.call_function(w_type, w_value)
                     w_type = space.exception_getclass(w_value)
 
-        elif space.full_exceptions and space.is_w(space.type(w_type),
-                                                  space.w_str):
-            space.warn("raising a string exception is deprecated", 
-                       space.w_DeprecationWarning)
-
         else:
             # the only case left here is (inst, None), from a 'raise inst'.
             w_inst = w_type
             w_instclass = space.exception_getclass(w_inst)
             if not space.exception_is_valid_class_w(w_instclass):
                 instclassname = w_instclass.getname(space, '?')
-                msg = ("exceptions must be classes, or instances, "
-                       "or strings (deprecated), not %s")
+                msg = ("exceptions must be old-style classes or derived "
+                       "from BaseException, not %s")
                 raise operationerrfmt(space.w_TypeError, msg, instclassname)
 
             if not space.is_w(w_value, space.w_None):

Modified: pypy/branch/fast-forward/pypy/interpreter/test/test_generator.py
==============================================================================
--- pypy/branch/fast-forward/pypy/interpreter/test/test_generator.py	(original)
+++ pypy/branch/fast-forward/pypy/interpreter/test/test_generator.py	Sun Oct 17 01:29:28 2010
@@ -89,9 +89,10 @@
                 pass
         g = f()
         g.next()
-        # String exceptions are allowed (with DeprecationWarning)
-        assert g.throw("Error") == 3
-        raises(StopIteration, g.throw, "Error")
+        # String exceptions are not allowed anymore
+        raises(TypeError, g.throw, "Error")
+        assert g.throw(Exception) == 3
+        raises(StopIteration, g.throw, Exception)
 
     def test_throw6(self):
         def f():



More information about the Pypy-commit mailing list