[Python-checkins] CVS: python/dist/src/Objects abstract.c,2.93.6.1,2.93.6.2

Michael Hudson mwh@users.sourceforge.net
Mon, 11 Mar 2002 02:11:48 -0800


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

Modified Files:
      Tag: release22-maint
	abstract.c 
Log Message:
backport jhylton's checkin of
    revision 2.97 of abstract.c

Fix for SF bug 516727: MyInt(2) + "3" -> NotImplemented

PyNumber_Add() tries the nb_add slot first, then falls back to
sq_concat.  However, it didn't check the return value of sq_concat.
If sq_concat returns NotImplemented, raise the standard TypeError.


Index: abstract.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/abstract.c,v
retrieving revision 2.93.6.1
retrieving revision 2.93.6.2
diff -C2 -d -r2.93.6.1 -r2.93.6.2
*** abstract.c	5 Jan 2002 10:52:38 -0000	2.93.6.1
--- abstract.c	11 Mar 2002 10:11:46 -0000	2.93.6.2
***************
*** 606,614 ****
  	if (result == Py_NotImplemented) {
  		PySequenceMethods *m = v->ob_type->tp_as_sequence;
! 		Py_DECREF(Py_NotImplemented);
! 		if (m && m->sq_concat) {
  			result = (*m->sq_concat)(v, w);
! 		}
!                 else {
                      PyErr_Format(
  			    PyExc_TypeError,
--- 606,613 ----
  	if (result == Py_NotImplemented) {
  		PySequenceMethods *m = v->ob_type->tp_as_sequence;
! 		Py_DECREF(result);
! 		if (m && m->sq_concat)
  			result = (*m->sq_concat)(v, w);
! 		if (result == Py_NotImplemented) {
                      PyErr_Format(
  			    PyExc_TypeError,