[pypy-svn] r32292 - in pypy/dist/pypy/module/rctime: . test

rhymes at codespeak.net rhymes at codespeak.net
Thu Sep 14 09:52:19 CEST 2006


Author: rhymes
Date: Thu Sep 14 09:52:17 2006
New Revision: 32292

Modified:
   pypy/dist/pypy/module/rctime/interp_time.py
   pypy/dist/pypy/module/rctime/test/test_rctime.py
Log:
fixed tuple length checking in strftime and asctime

Modified: pypy/dist/pypy/module/rctime/interp_time.py
==============================================================================
--- pypy/dist/pypy/module/rctime/interp_time.py	(original)
+++ pypy/dist/pypy/module/rctime/interp_time.py	Thu Sep 14 09:52:17 2006
@@ -342,8 +342,7 @@
     if not space.is_w(w_tup, space.w_None):
         tuple_len = space.int_w(space.len(w_tup))
         
-        # if space.is_w(w_tup, space.w_None) or 1 < tuple_len < 9:
-        if 1 < tuple_len < 9:
+        if tuple_len < 9:
             raise OperationError(space.w_TypeError, 
                 space.wrap("argument must be 9-item sequence"))
     
@@ -483,8 +482,7 @@
     if not space.is_w(w_tup, space.w_None):
         tuple_len = space.int_w(space.len(w_tup))
         
-        #if space.is_w(w_tup, space.w_None) or 1 < tuple_len < 9:
-        if 1 < tuple_len < 9:
+        if tuple_len < 9:
             raise OperationError(space.w_TypeError, 
                 space.wrap("argument must be 9-item sequence"))
 

Modified: pypy/dist/pypy/module/rctime/test/test_rctime.py
==============================================================================
--- pypy/dist/pypy/module/rctime/test/test_rctime.py	(original)
+++ pypy/dist/pypy/module/rctime/test/test_rctime.py	Thu Sep 14 09:52:17 2006
@@ -108,6 +108,9 @@
         import rctime
         rctime.asctime()
         # raises(TypeError, rctime.asctime, None)
+        raises(TypeError, rctime.asctime, ())
+        raises(TypeError, rctime.asctime, (1,))
+        raises(TypeError, rctime.asctime, range(8))
         raises(TypeError, rctime.asctime, (1, 2))
         raises(TypeError, rctime.asctime, (1, 2, 3, 4, 5, 6, 'f', 8, 9))
         raises(TypeError, rctime.asctime, "foo")
@@ -205,6 +208,10 @@
                           'U', 'w', 'W', 'x', 'X', 'y', 'Y', 'Z', '%'):
             format = ' %' + directive
             rctime.strftime(format, tt)
+        
+        raises(TypeError, rctime.strftime, ())
+        raises(TypeError, rctime.strftime, (1,))
+        raises(TypeError, rctime.strftime, range(8))
 
     def test_strftime_bounds_checking(self):
         import rctime



More information about the Pypy-commit mailing list