Author rshapiro
Recipients rshapiro
Date 2009-09-02.15:40:49
SpamBayes Score 1.74183e-12
Marked as misclassified No
Message-id <1251906051.81.0.942074704483.issue6823@psf.upfronthosting.co.za>
In-reply-to
Content
in Modules/timemodule.c, in the routine time_strftime, there is a range
check on the tm_isdst field:

        if (buf.tm_isdst < -1 || buf.tm_isdst > 1) {
            PyErr_SetString(PyExc_ValueError,
                            "daylight savings flag out of range");
            return NULL;
        }

This check is incorrect, as the tm_isdst field is interpreted as less
than 0, 0, or greater than zero (see the comment at the top of the
routine, and the documentation for the strftime function).
Unfortunately, there exists at least one platform for which tm_isdst is
set to something other than -1, 0, or 1 (on IBM zOS it's apparently set
to 2 for daylight savings). This means that you can't do the obvious 
strftime(...,localtime(...)) to format a time.

The fix is to either remove the range check entirely, or else to
normalize the +1, -1, or 0. The former is preferred unless there is some
platform on which strftime doesn't do the right thing with values
outside the range of [-1,1]. 

This bug exists in 2.5.1 and 2.6.2. I haven't checked other versions.
History
Date User Action Args
2009-09-02 15:40:51rshapirosetrecipients: + rshapiro
2009-09-02 15:40:51rshapirosetmessageid: <1251906051.81.0.942074704483.issue6823@psf.upfronthosting.co.za>
2009-09-02 15:40:50rshapirolinkissue6823 messages
2009-09-02 15:40:49rshapirocreate