[Python-checkins] python/dist/src/Objects typeobject.c,2.238,2.239

jhylton@users.sourceforge.net jhylton@users.sourceforge.net
Fri, 27 Jun 2003 10:38:33 -0700


Update of /cvsroot/python/python/dist/src/Objects
In directory sc8-pr-cvs1:/tmp/cvs-serv22884

Modified Files:
	typeobject.c 
Log Message:
Require that __nonzero__() return a bool or exactly an int.


Index: typeobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/typeobject.c,v
retrieving revision 2.238
retrieving revision 2.239
diff -C2 -d -r2.238 -r2.239
*** typeobject.c	27 Jun 2003 16:46:45 -0000	2.238
--- typeobject.c	27 Jun 2003 17:38:27 -0000	2.239
***************
*** 4197,4205 ****
  		Py_DECREF(args);
  		if (temp != NULL) {
! 			if (PyInt_Check(temp)) {
! 				/* XXX need to guard against recursion here */
! 				result = PyObject_IsTrue(temp);
! 			}
! 			else if (PyBool_Check(temp))
  				result = PyObject_IsTrue(temp);
  			else {
--- 4197,4201 ----
  		Py_DECREF(args);
  		if (temp != NULL) {
! 			if (PyInt_CheckExact(temp) || PyBool_Check(temp))
  				result = PyObject_IsTrue(temp);
  			else {
***************
*** 4208,4212 ****
  					     "bool or int, returned %s",
  					     temp->ob_type->tp_name);
! 				result = NULL;
  			}
  			Py_DECREF(temp);
--- 4204,4208 ----
  					     "bool or int, returned %s",
  					     temp->ob_type->tp_name);
! 				result = -1;
  			}
  			Py_DECREF(temp);