diff options
-rw-r--r-- | Lib/test/test_time.py | 5 | ||||
-rw-r--r-- | Misc/ACKS | 1 | ||||
-rw-r--r-- | Modules/timemodule.c | 12 |
3 files changed, 8 insertions, 10 deletions
diff --git a/Lib/test/test_time.py b/Lib/test/test_time.py index 49a9d17..4ce90e9 100644 --- a/Lib/test/test_time.py +++ b/Lib/test/test_time.py @@ -87,11 +87,6 @@ class TimeTestCase(unittest.TestCase): (1900, 1, 1, 0, 0, 0, 0, -1, -1)) self.assertRaises(ValueError, time.strftime, '', (1900, 1, 1, 0, 0, 0, 0, 367, -1)) - # Check daylight savings flag [-1, 1] - self.assertRaises(ValueError, time.strftime, '', - (1900, 1, 1, 0, 0, 0, 0, 1, -2)) - self.assertRaises(ValueError, time.strftime, '', - (1900, 1, 1, 0, 0, 0, 0, 1, 2)) def test_default_values_for_zero(self): # Make sure that using all zeros uses the proper default values. @@ -674,6 +674,7 @@ Jerry Seutter Denis Severson Ian Seyer Ha Shao +Richard Shapiro Bruce Sherwood Pete Shinners Michael Shiplett diff --git a/Modules/timemodule.c b/Modules/timemodule.c index d8db409..af0e1a7 100644 --- a/Modules/timemodule.c +++ b/Modules/timemodule.c @@ -512,11 +512,13 @@ time_strftime(PyObject *self, PyObject *args) PyErr_SetString(PyExc_ValueError, "day of year out of range"); return NULL; } - if (buf.tm_isdst < -1 || buf.tm_isdst > 1) { - PyErr_SetString(PyExc_ValueError, - "daylight savings flag out of range"); - return NULL; - } + /* 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 (buf.tm_isdst < -1) + buf.tm_isdst = -1; + else if (buf.tm_isdst > 1) + buf.tm_isdst = 1; #ifdef HAVE_WCSFTIME tmpfmt = PyBytes_FromStringAndSize(NULL, |