[Python-checkins] python/dist/src/Objects typeobject.c,2.246,2.247

rhettinger at users.sourceforge.net rhettinger at users.sourceforge.net
Sat Oct 11 13:29:07 EDT 2003


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

Modified Files:
	typeobject.c 
Log Message:
SF bug #820397:  __nonzero__() returns 1/0

Altered to return a PyBool instead of a PyInt.

Backport candidate.



Index: typeobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/typeobject.c,v
retrieving revision 2.246
retrieving revision 2.247
diff -C2 -d -r2.246 -r2.247
*** typeobject.c	9 Oct 2003 03:46:35 -0000	2.246
--- typeobject.c	11 Oct 2003 17:29:04 -0000	2.247
***************
*** 3327,3330 ****
--- 3327,3344 ----
  
  static PyObject *
+ wrap_inquirypred(PyObject *self, PyObject *args, void *wrapped)
+ {
+ 	inquiry func = (inquiry)wrapped;
+ 	int res;
+ 
+ 	if (!PyArg_ParseTuple(args, ""))
+ 		return NULL;
+ 	res = (*func)(self);
+ 	if (res == -1 && PyErr_Occurred())
+ 		return NULL;
+ 	return PyBool_FromLong((long)res);
+ }
+ 
+ static PyObject *
  wrap_binaryfunc(PyObject *self, PyObject *args, void *wrapped)
  {
***************
*** 4915,4919 ****
  	UNSLOT("__abs__", nb_absolute, slot_nb_absolute, wrap_unaryfunc,
  	       "abs(x)"),
! 	UNSLOT("__nonzero__", nb_nonzero, slot_nb_nonzero, wrap_inquiry,
  	       "x != 0"),
  	UNSLOT("__invert__", nb_invert, slot_nb_invert, wrap_unaryfunc, "~x"),
--- 4929,4933 ----
  	UNSLOT("__abs__", nb_absolute, slot_nb_absolute, wrap_unaryfunc,
  	       "abs(x)"),
! 	UNSLOT("__nonzero__", nb_nonzero, slot_nb_nonzero, wrap_inquirypred,
  	       "x != 0"),
  	UNSLOT("__invert__", nb_invert, slot_nb_invert, wrap_unaryfunc, "~x"),





More information about the Python-checkins mailing list