Commits

Philip Jenvey committed e4fa0b2

be less strict about tm_wday to match cpython

Comments (0)

Files changed (2)

pypy/module/rctime/interp_time.py

             raise OperationError(space.w_ValueError,
                 space.wrap("year out of range"))
 
-    if rffi.getintfield(glob_buf, 'c_tm_wday') < 0:
-        raise OperationError(space.w_ValueError,
-                             space.wrap("day of week out of range"))
-
     rffi.setintfield(glob_buf, 'c_tm_year', y - 1900)
     rffi.setintfield(glob_buf, 'c_tm_mon',
                      rffi.getintfield(glob_buf, 'c_tm_mon') - 1)
     rffi.setintfield(glob_buf, 'c_tm_yday',
                      rffi.getintfield(glob_buf, 'c_tm_yday') - 1)
 
+    # tm_wday does not need checking of its upper-bound since taking "%
+    #  7" in gettmarg() automatically restricts the range.
+    if rffi.getintfield(glob_buf, 'c_tm_wday') < 0:
+        raise OperationError(space.w_ValueError,
+                             space.wrap("day of week out of range"))
+
     return glob_buf
 
 def time(space):

pypy/module/rctime/test/test_rctime.py

         if os.name != 'nt':
             assert rctime.mktime(rctime.localtime(-1)) == -1
 
+        res = rctime.mktime((2000, 1, 1, 0, 0, 0, -1, -1, -1))
+        assert rctime.ctime(res) == 'Sat Jan  1 00:00:00 2000'
+
     def test_asctime(self):
         import time as rctime
         rctime.asctime()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.