Index: setup.py =================================================================== --- setup.py (revision 82017) +++ setup.py (working copy) @@ -450,9 +450,9 @@ depends=['_math.h'], libraries=math_libs) ) # time operations and variables - exts.append( Extension('time', ['timemodule.c'], + exts.append( Extension('time', ['timemodule.c', '_time.c'], libraries=math_libs) ) - exts.append( Extension('datetime', ['datetimemodule.c', 'timemodule.c'], + exts.append( Extension('datetime', ['datetimemodule.c', '_time.c'], libraries=math_libs) ) # fast iterator tools implemented in C exts.append( Extension("itertools", ["itertoolsmodule.c"]) ) Index: Modules/_time.c =================================================================== --- Modules/_time.c (revision 0) +++ Modules/_time.c (revision 0) @@ -0,0 +1,28 @@ +#include "Python.h" +#include "_time.h" + +/* Exposed in timefuncs.h. */ +time_t +_PyTime_DoubleToTimet(double x) +{ + time_t result; + double diff; + + result = (time_t)x; + /* How much info did we lose? time_t may be an integral or + * floating type, and we don't know which. If it's integral, + * we don't know whether C truncates, rounds, returns the floor, + * etc. If we lost a second or more, the C rounding is + * unreasonable, or the input just doesn't fit in a time_t; + * call it an error regardless. Note that the original cast to + * time_t can cause a C error too, but nothing we can do to + * worm around that. + */ + diff = x - (double)result; + if (diff <= -1.0 || diff >= 1.0) { + PyErr_SetString(PyExc_ValueError, + "timestamp out of range for platform time_t"); + result = (time_t)-1; + } + return result; +} Index: Modules/_time.h =================================================================== --- Modules/_time.h (revision 0) +++ Modules/_time.h (revision 0) @@ -0,0 +1,3 @@ +/* XXX: It is probably best to move timefuncs.h content in here, and + remove it but user code may rely on it. */ +#include "timefuncs.h" Index: Modules/timemodule.c =================================================================== --- Modules/timemodule.c (revision 82017) +++ Modules/timemodule.c (working copy) @@ -90,32 +90,6 @@ /* For Y2K check */ static PyObject *moddict; -/* Exposed in timefuncs.h. */ -time_t -_PyTime_DoubleToTimet(double x) -{ - time_t result; - double diff; - - result = (time_t)x; - /* How much info did we lose? time_t may be an integral or - * floating type, and we don't know which. If it's integral, - * we don't know whether C truncates, rounds, returns the floor, - * etc. If we lost a second or more, the C rounding is - * unreasonable, or the input just doesn't fit in a time_t; - * call it an error regardless. Note that the original cast to - * time_t can cause a C error too, but nothing we can do to - * worm around that. - */ - diff = x - (double)result; - if (diff <= -1.0 || diff >= 1.0) { - PyErr_SetString(PyExc_ValueError, - "timestamp out of range for platform time_t"); - result = (time_t)-1; - } - return result; -} - static PyObject * time_time(PyObject *self, PyObject *unused) {