[pypy-commit] pypy py3k: Merged in marky1991/pypy_new/py3k-finish_time (pull request #465)
rlamy
pypy.commits at gmail.com
Tue Aug 2 18:03:17 EDT 2016
Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: py3k
Changeset: r85997:b5091dc062fd
Date: 2016-08-02 23:02 +0100
http://bitbucket.org/pypy/pypy/changeset/b5091dc062fd/
Log: Merged in marky1991/pypy_new/py3k-finish_time (pull request #465)
Make all tests pass for the time module.
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
More information about the pypy-commit
mailing list