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

Jeremy Hylton jhylton@users.sourceforge.net
Fri, 08 Mar 2002 13:11:39 -0800


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

Modified Files:
	abstract.c 
Log Message:
Fix for SF bug 516727: MyInt(2) + "3" -> NotImplemented

PyNumber_Add() tries the nb_add slot first, then falls back to
sq_concat.  However, tt 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.96
retrieving revision 2.97
diff -C2 -d -r2.96 -r2.97
*** abstract.c	2 Mar 2002 04:14:21 -0000	2.96
--- abstract.c	8 Mar 2002 21:11:37 -0000	2.97
***************
*** 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,