[Python-checkins] python/dist/src/Modules datetimemodule.c,1.5,1.6
tim_one@users.sourceforge.net
tim_one@users.sourceforge.net
Wed, 18 Dec 2002 17:44:40 -0800
Update of /cvsroot/python/python/dist/src/Modules
In directory sc8-pr-cvs1:/tmp/cvs-serv21782/python/Modules
Modified Files:
datetimemodule.c
Log Message:
Fixed typo in string.
Index: datetimemodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/datetimemodule.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** datetimemodule.c 19 Dec 2002 00:42:03 -0000 1.5
--- datetimemodule.c 19 Dec 2002 01:44:38 -0000 1.6
***************
*** 1327,1330 ****
--- 1327,1331 ----
int s;
int d;
+ long temp;
PyObject *tuple = NULL;
***************
*** 1339,1344 ****
if (num == NULL)
goto Done;
! us = PyLong_AsLong(num);
num = NULL;
if (us < 0) {
/* The divisor was positive, so this must be an error. */
--- 1340,1349 ----
if (num == NULL)
goto Done;
! temp = PyLong_AsLong(num);
num = NULL;
+ if (temp == -1 && PyErr_Occurred())
+ goto Done;
+ assert(0 <= temp && temp < 1000000);
+ us = (int)temp;
if (us < 0) {
/* The divisor was positive, so this must be an error. */
***************
*** 1361,1366 ****
if (num == NULL)
goto Done;
! s = PyLong_AsLong(num);
num = NULL;
if (s < 0) {
/* The divisor was positive, so this must be an error. */
--- 1366,1376 ----
if (num == NULL)
goto Done;
! temp = PyLong_AsLong(num);
num = NULL;
+ if (temp == -1 && PyErr_Occurred())
+ goto Done;
+ assert(0 <= temp && temp < 24*3600);
+ s = (int)temp;
+
if (s < 0) {
/* The divisor was positive, so this must be an error. */
***************
*** 1373,1380 ****
goto Done;
Py_INCREF(num);
!
! d = PyLong_AsLong(num);
! if (d == -1 && PyErr_Occurred())
goto Done;
result = new_delta(d, s, us, 0);
--- 1383,1395 ----
goto Done;
Py_INCREF(num);
! temp = PyLong_AsLong(num);
! if (temp == -1 && PyErr_Occurred())
goto Done;
+ d = (int)temp;
+ if ((long)d != temp) {
+ PyErr_SetString(PyExc_OverflowError, "normalized days too "
+ "large to fit in a C int");
+ goto Done;
+ }
result = new_delta(d, s, us, 0);