[pypy-svn] r38661 - in pypy/dist/pypy/module/__builtin__: . test

cfbolz at codespeak.net cfbolz at codespeak.net
Tue Feb 13 10:06:24 CET 2007


Author: cfbolz
Date: Tue Feb 13 10:06:24 2007
New Revision: 38661

Modified:
   pypy/dist/pypy/module/__builtin__/functional.py
   pypy/dist/pypy/module/__builtin__/test/test_range.py
Log:
fix bogus exception handling and add a test that would have caught it.


Modified: pypy/dist/pypy/module/__builtin__/functional.py
==============================================================================
--- pypy/dist/pypy/module/__builtin__/functional.py	(original)
+++ pypy/dist/pypy/module/__builtin__/functional.py	Tue Feb 13 10:06:24 2007
@@ -78,11 +78,12 @@
         step = space.int_w(w_step)
         howmany = get_len_of_range(start, stop, step)
     except OperationError, e:
-        if not e.match(space.w_TypeError):
+        if not e.match(space, space.w_TypeError):
+            pass
+        else:
             raise
     except (ValueError, OverflowError):
         pass
-        return range_fallback(space, w_x, w_y, w_step)
     else:
         if (space.config.objspace.name == "std" and
             (space.config.objspace.std.withmultilist or
@@ -95,6 +96,7 @@
             res_w[idx] = space.wrap(v)
             v += step
         return space.newlist(res_w)
+    return range_fallback(space, w_x, w_y, w_step)
 range_int = range
 range_int.unwrap_spec = [ObjSpace, W_Root, W_Root, W_Root]
 del range # don't hide the builtin one

Modified: pypy/dist/pypy/module/__builtin__/test/test_range.py
==============================================================================
--- pypy/dist/pypy/module/__builtin__/test/test_range.py	(original)
+++ pypy/dist/pypy/module/__builtin__/test/test_range.py	Tue Feb 13 10:06:24 2007
@@ -52,16 +52,18 @@
        assert range (-1, -12, -3) == [-1, -4, -7, -10]
 
    def test_range_decreasing_negativelargestep(self):
-      assert range(5, -2, -3) == [5, 2, -1]
+       assert range(5, -2, -3) == [5, 2, -1]
 
    def test_range_increasing_positivelargestep(self):
-      assert range(-5, 2, 3) == [-5, -2, 1]
+       assert range(-5, 2, 3) == [-5, -2, 1]
 
    def test_range_zerostep(self):
-      raises(ValueError, range, 1, 5, 0)
+       raises(ValueError, range, 1, 5, 0)
+
+   def DONT_test_range_float(self):
+       "How CPython does it - UGLY, ignored for now."
+       assert range(0.1, 2.0, 1.1) == [0, 1]
+
+   def test_range_wrong_type(self):
+       raises(TypeError, range, "42")
 
-"""
-   def test_range_float(self):
-      "How CPython does it - UGLY, ignored for now."
-      assert range(0.1, 2.0, 1.1) == [0, 1]
-      """



More information about the Pypy-commit mailing list