Author trent
Recipients trent
Date 2012-08-21.06:47:49
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1345531691.61.0.215808294291.issue15750@psf.upfronthosting.co.za>
In-reply-to
Content
All my servers are set to use UTC, which affects how FreeBSD (and other BSDs) treat the isdst param in struct tm in mktime:


#include <stdio.h>
#include <string.h>
#include <time.h>

int main(int argc, char **argv)
{
    struct tm tm1, tm2;
    time_t t1, t2;

    memset((void *)&tm1, 0, sizeof(struct tm));
    memset((void *)&tm2, 0, sizeof(struct tm));

    // UTC
    setenv("TZ", "UTC", 1);
    tzset();

    tm1.tm_sec = 0;
    tm1.tm_min = 1;
    tm1.tm_hour = 1;
    tm1.tm_mday = 12;
    tm1.tm_mon = 3;
    tm1.tm_year = 2012;
    tm1.tm_wday = -1;
    tm1.tm_yday = -1;
    tm1.tm_isdst = 1;

    t1 = mktime(&tm1);
    printf("t1 (UTC): %d\n", t1);

    // EST
    setenv("TZ", "CET", 1);
    tzset();
    tm2.tm_sec = 0;
    tm2.tm_min = 1;
    tm2.tm_hour = 1;
    tm2.tm_mday = 12;
    tm2.tm_mon = 3;
    tm2.tm_year = 2012;

    tm2.tm_wday = -1;
    tm2.tm_yday = -1;
    tm2.tm_isdst = 1;

    t2 = mktime(&tm2);
    printf("t2 (CET): %d\n", t2);

    return 0;
}


% gcc -g test_mktime.c -o test_time && ./test_time 
t1 (UTC): -1
t2 (CET): 1162787116

The two tests causing problems are Lib/test/test_email/test_utils.py:


    def test_localtime_daylight_false_dst_false(self):
        test.support.patch(self, time, 'daylight', False)
        t0 = datetime.datetime(2012, 3, 12, 1, 1)
        t1 = utils.localtime(t0, isdst=-1)
        t2 = utils.localtime(t1)
        self.assertEqual(t1, t2)

    def test_localtime_daylight_true_dst_true(self):
        test.support.patch(self, time, 'daylight', True)
        t0 = datetime.datetime(2012, 3, 12, 1, 1)
        t1 = utils.localtime(t0, isdst=1)
        t2 = utils.localtime(t1)
        self.assertEqual(t1, t2)


In order for those tests to work on a *BSD server with a TZ set to UTC, TZ is going to need to be set to something else first, and then tzset() called.  Otherwise, mktime() will return -1, which triggers the overflow error.
History
Date User Action Args
2012-08-21 06:48:11trentsetrecipients: + trent
2012-08-21 06:48:11trentsetmessageid: <1345531691.61.0.215808294291.issue15750@psf.upfronthosting.co.za>
2012-08-21 06:47:50trentlinkissue15750 messages
2012-08-21 06:47:49trentcreate