[pypy-commit] pypy py3k: Fix time module to pass tests.
amauryfa
noreply at buildbot.pypy.org
Mon Oct 22 00:34:22 CEST 2012
Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: py3k
Changeset: r58348:256ceebd14f3
Date: 2012-10-21 16:00 +0200
http://bitbucket.org/pypy/pypy/changeset/256ceebd14f3/
Log: Fix time module to pass tests.
diff --git a/pypy/module/rctime/interp_time.py b/pypy/module/rctime/interp_time.py
--- a/pypy/module/rctime/interp_time.py
+++ b/pypy/module/rctime/interp_time.py
@@ -436,17 +436,14 @@
accept2dyear = space.int_w(w_accept2dyear)
if y < 1900:
- if not accept2dyear:
- raise OperationError(space.w_ValueError,
- space.wrap("year >= 1900 required"))
-
- if 69 <= y <= 99:
- y += 1900
- elif 0 <= y <= 68:
- y += 2000
- else:
- raise OperationError(space.w_ValueError,
- space.wrap("year out of range"))
+ if accept2dyear:
+ if 69 <= y <= 99:
+ y += 1900
+ elif 0 <= y <= 68:
+ y += 2000
+ else:
+ 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,
@@ -625,9 +622,13 @@
if rffi.getintfield(buf_value, 'c_tm_yday') < 0 or rffi.getintfield(buf_value, 'c_tm_yday') > 365:
raise OperationError(space.w_ValueError,
space.wrap("day of year out of range"))
- if rffi.getintfield(buf_value, 'c_tm_isdst') < -1 or rffi.getintfield(buf_value, 'c_tm_isdst') > 1:
- raise OperationError(space.w_ValueError,
- space.wrap("daylight savings flag out of range"))
+ # Normalize tm_isdst just in case someone foolishly implements %Z
+ # based on the assumption that tm_isdst falls within the range of
+ # [-1, 1]
+ if rffi.getintfield(buf_value, 'c_tm_isdst') < -1:
+ 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)
if _WIN:
# check that the format string contains only valid directives
More information about the pypy-commit
mailing list