summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
Diffstat (limited to 'Modules')
-rw-r--r--Modules/timemodule.c12
1 files changed, 7 insertions, 5 deletions
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,