[issue13309] test_time fails: time data 'LMT' does not match format '%Z'

Antoine Pitrou report at bugs.python.org
Fri Nov 11 00:38:14 CET 2011


Antoine Pitrou <pitrou at free.fr> added the comment:

It is definitely a glibc issue. Here's a C snippet to reproduce:

"""
#include <time.h>
#include <stdlib.h>

int main() {
    time_t t;
    struct tm tmp;
    char str[200];

    t = time(NULL);
    tmp = *gmtime(&t);
    tmp.tm_gmtoff = 0;
    tmp.tm_zone = NULL;

    strftime(str, sizeof(str), "%Z", &tmp);
    puts(str);

    t = -2461446500;
    localtime(&t);

    t = time(NULL);
    tmp = *gmtime(&t);
    tmp.tm_gmtoff = 0;
    tmp.tm_zone = NULL;

    strftime(str, sizeof(str), "%Z", &tmp);
    puts(str);

    return 0;
}
"""

Output:
CET
PMT


Calling localtime() or mktime() with a time largely in the past seems to corrupt the glibc's internal time structures (the "char *tm_zone[]").

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue13309>
_______________________________________


More information about the Python-bugs-list mailing list