DragonFly users List (threaded) for 2008-09
[
Date Prev][
Date Next]
[
Thread Prev][
Thread Next]
[
Date Index][
Thread Index]
python mktime fails with overflow (same call works in other environments)
mktime is failing in python2.4 and python2.5 under DragonflyBSD 2.0
for certain date/times:
>>> from time import mktime
>>> tt=(2006, 4, 2, 2, 16, 27, -1, -1, -1)
>>> mktime(tt)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
OverflowError: mktime argument out of range
When I run the above python snippet on any other system I have access
to (Fedora 9, OpenBSD 4.1, etc.) I get:
>>> mktime(tt)
1143944187.0
(Note, this is with TZ=GMT, it still fails no matter what I set the TZ
to.)
When I wrote a c program and a perl snippet to make the same mktime
call as above, it worked on every system I tested it on (including
Dragonfly). They all give 1143944187. (The way you call mktime
differs slightly of course.)
Other mktime calls work in python under dragonflybsd, but it isn't
hard to concoct other variations of the above time that fail in the
same way.
I can only assume that python is calling mktime incorrectly under
dragonflybsd? Unless someone has a suggestion I may look at the
python source code, which sounds daunting. For the record I'll
include my perl snippet:
perl -MPOSIX -e 'print mktime(27,16,2,2,(4-1),(2006-1900),-1,-1,-1)."\n";'
and attach the c program.
#include <time.h>
#include <stdio.h>
/* (2006, 4, 2, 2, 16, 27, -1, -1, -1) */
struct tm ts;
main() {
ts.tm_sec=27;
ts.tm_min=16;
ts.tm_hour=2;
ts.tm_mday=2;
ts.tm_mon=(4-1);
ts.tm_year=(2006-1900);
// ts.tm_wday=-1;
// ts.tm_yday=-1;
//ts.tm_isdst=-1;
printf("%d\n",mktime(&ts));
}
[
Date Prev][
Date Next]
[
Thread Prev][
Thread Next]
[
Date Index][
Thread Index]