[Python-checkins] python/nondist/sandbox/datetime obj_date.c,1.15,1.16 obj_datetime.c,1.9,1.10

tim_one@users.sourceforge.net tim_one@users.sourceforge.net
Mon, 02 Dec 2002 14:07:24 -0800


Update of /cvsroot/python/python/nondist/sandbox/datetime
In directory sc8-pr-cvs1:/tmp/cvs-serv10012

Modified Files:
	obj_date.c obj_datetime.c 
Log Message:
Old bug in date and datetime comparison, not noticed before because the
TypeError code was unreachable:  use PyErr_Format instead of PyErr_String,
because these guys are trying to give the name of the offending type.


Index: obj_date.c
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/datetime/obj_date.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** obj_date.c	2 Dec 2002 21:50:57 -0000	1.15
--- obj_date.c	2 Dec 2002 22:07:16 -0000	1.16
***************
*** 105,110 ****
  
  	if (! PyType_IsSubtype(other->ob_type, &PyDateTime_DateType)) {
! 		PyErr_SetString(PyExc_TypeError,
! 				"can't compare date to %s instance");
  		return NULL;
  	}
--- 105,111 ----
  
  	if (! PyType_IsSubtype(other->ob_type, &PyDateTime_DateType)) {
! 		PyErr_Format(PyExc_TypeError,
! 			     "can't compare date to %s instance",
! 			     other->ob_type->tp_name);
  		return NULL;
  	}

Index: obj_datetime.c
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/datetime/obj_datetime.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** obj_datetime.c	2 Dec 2002 21:55:21 -0000	1.9
--- obj_datetime.c	2 Dec 2002 22:07:17 -0000	1.10
***************
*** 136,141 ****
  
  	if (!PyType_IsSubtype(other->ob_type, &PyDateTime_DateTimeType)) {
! 		PyErr_SetString(PyExc_TypeError,
! 				"can't compare date to %s instance");
  		return NULL;
  	}
--- 136,142 ----
  
  	if (!PyType_IsSubtype(other->ob_type, &PyDateTime_DateTimeType)) {
! 		PyErr_Format(PyExc_TypeError,
! 			     "can't compare datetime to %s instance",
! 			     other->ob_type->tp_name);
  		return NULL;
  	}