Author: Mark Young <[email protected]>
Branch: py3k-finish_time
Changeset: r85996:80df0bb39be6
Date: 2016-07-17 23:51 -0400
http://bitbucket.org/pypy/pypy/changeset/80df0bb39be6/

Log:    Make all tests pass for the time module. lib-python/test_time.py
        still fails test_mktime_error when run untranslated, but this test
        is skipped when run translated anyway.

diff --git a/pypy/module/time/interp_time.py b/pypy/module/time/interp_time.py
--- a/pypy/module/time/interp_time.py
+++ b/pypy/module/time/interp_time.py
@@ -541,6 +541,8 @@
         t_ref = lltype.malloc(rffi.TIME_TP.TO, 1, flavor='raw')
         t_ref[0] = tt
         pbuf = c_localtime(t_ref)
+        rffi.setintfield(pbuf, "c_tm_year",
+                         rffi.getintfield(pbuf, "c_tm_year") + 1900)
         lltype.free(t_ref, flavor='raw')
         if not pbuf:
             raise OperationError(space.w_ValueError,
@@ -584,7 +586,7 @@
     if rffi.getintfield(glob_buf, 'c_tm_wday') < -1:
         raise oefmt(space.w_ValueError, "day of week out of range")
 
-    rffi.setintfield(glob_buf, 'c_tm_year', y - 1900)
+    rffi.setintfield(glob_buf, 'c_tm_year', y)
     rffi.setintfield(glob_buf, 'c_tm_mon',
                      rffi.getintfield(glob_buf, 'c_tm_mon') - 1)
     rffi.setintfield(glob_buf, 'c_tm_wday',
@@ -648,7 +650,8 @@
         t_ref[0] = seconds
         p = c_localtime(t_ref)
     if not p:
-        raise oefmt(space.w_ValueError, "unconvertible time")
+        raise oefmt(space.w_OSError, "unconvertible time")
+    rffi.setintfield(p, "c_tm_year", rffi.getintfield(p, "c_tm_year") + 1900)
     return _asctime(space, p)
 
 # by now w_tup is an optional argument (and not *args)
@@ -677,7 +680,7 @@
             w(getif(t_ref, 'c_tm_hour')),
             w(getif(t_ref, 'c_tm_min')),
             w(getif(t_ref, 'c_tm_sec')),
-            w(getif(t_ref, 'c_tm_year') + 1900)]
+            w(getif(t_ref, 'c_tm_year'))]
     return space.mod(w("%.3s %.3s%3d %.2d:%.2d:%.2d %d"),
                      space.newtuple(args))
 
@@ -715,7 +718,7 @@
     lltype.free(t_ref, flavor='raw')
 
     if not p:
-        raise OperationError(space.w_ValueError, space.wrap(_get_error_msg()))
+        raise OperationError(space.w_OSError, space.wrap(_get_error_msg()))
     return _tm_to_tuple(space, p)
 
 def mktime(space, w_tup):
@@ -725,6 +728,7 @@
 
     buf = _gettmarg(space, w_tup, allowNone=False)
     rffi.setintfield(buf, "c_tm_wday", -1)
+    rffi.setintfield(buf, "c_tm_year", rffi.getintfield(buf, "c_tm_year") - 
1900)
     tt = c_mktime(buf)
     # A return value of -1 does not necessarily mean an error, but tm_wday
     # cannot remain set to -1 if mktime succeeds.
@@ -801,6 +805,8 @@
         rffi.setintfield(buf_value, 'c_tm_isdst', -1)
     elif rffi.getintfield(buf_value, 'c_tm_isdst') > 1:
         rffi.setintfield(buf_value, 'c_tm_isdst', 1)
+    rffi.setintfield(buf_value, "c_tm_year",
+                     rffi.getintfield(buf_value, "c_tm_year") - 1900)
 
     if _WIN:
         # check that the format string contains only valid directives
@@ -970,8 +976,11 @@
              lltype.scoped_alloc(rwin32.FILETIME) as exit_time, \
              lltype.scoped_alloc(rwin32.FILETIME) as kernel_time, \
              lltype.scoped_alloc(rwin32.FILETIME) as user_time:
-            GetProcessTimes(current_process, creation_time, exit_time,
-                            kernel_time, user_time)
+            worked = GetProcessTimes(current_process, creation_time, exit_time,
+                                     kernel_time, user_time)
+            if not worked:
+                raise wrap_windowserror(space,
+                    rwin32.lastSavedWindowsError("GetProcessTimes"))
             kernel_time2 = (kernel_time.c_dwLowDateTime |
                             r_ulonglong(kernel_time.c_dwHighDateTime) << 32)
             user_time2 = (user_time.c_dwLowDateTime |
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to