summaryrefslogtreecommitdiff
path: root/Modules/timemodule.c
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2004-06-20 02:50:16 +0000
committerTim Peters <tim.peters@gmail.com>2004-06-20 02:50:16 +0000
commit46bfc4121ac28c7a63d79b0aa21beee252717a78 (patch)
tree608c7316024b01d0ec2f424407c1b7dccbfcea38 /Modules/timemodule.c
parente7eaa9e24de28f1800d0e0f5214ed8815024b2ea (diff)
downloadcpython-46bfc4121ac28c7a63d79b0aa21beee252717a78.tar.gz
Bug 975996: Add _PyTime_DoubleToTimet to C API
New include file timefuncs.h exports private API function _PyTime_DoubleToTimet() from timemodule.c. timemodule should export some other functions too (look for painful bits in datetimemodule.c). Added insane-argument checking to datetime's assorted fromtimestamp() and utcfromtimestamp() methods. Added insane-argument tests of these to test_datetime, and insane-argument tests for ctime(), localtime() and gmtime() to test_time.
Diffstat (limited to 'Modules/timemodule.c')
-rw-r--r--Modules/timemodule.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/Modules/timemodule.c b/Modules/timemodule.c
index 0783f7f783..f8557968f5 100644
--- a/Modules/timemodule.c
+++ b/Modules/timemodule.c
@@ -3,6 +3,7 @@
#include "Python.h"
#include "structseq.h"
+#include "timefuncs.h"
#include <ctype.h>
@@ -84,11 +85,8 @@ static double floattime(void);
/* For Y2K check */
static PyObject *moddict;
-/* Cast double x to time_t, but raise ValueError if x is too large
- * to fit in a time_t. ValueError is set on return iff the return
- * value is (time_t)-1 and PyErr_Occurred().
- */
-static time_t
+/* Exposed in timefuncs.h. */
+time_t
_PyTime_DoubleToTimet(double x)
{
time_t result;
@@ -382,7 +380,7 @@ time_strftime(PyObject *self, PyObject *args)
/* Checks added to make sure strftime() does not crash Python by
indexing blindly into some array for a textual representation
by some bad index (fixes bug #897625).
-
+
No check for year since handled in gettmarg().
*/
if (buf.tm_mon < 0 || buf.tm_mon > 11) {
@@ -583,7 +581,7 @@ time_tzset(PyObject *self, PyObject *args)
/* Reset timezone, altzone, daylight and tzname */
inittimezone(m);
Py_DECREF(m);
-
+
Py_INCREF(Py_None);
return Py_None;
}