(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.
Extension Modules
-----------------
+- Issue #6823: Allow time.strftime() to accept a tuple with a isdst field
+ outside of the range of [-1, 1] by normalizing the value to within that
+ range.
+
- Issue #6877: Make it possible to link the readline extension to libedit
on OSX.
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 MS_WINDOWS
/* check that the format string contains only valid directives */