[Python-checkins] CVS: python/dist/src/Objects abstract.c,2.85,2.86 stringobject.c,2.139,2.140

Guido van Rossum gvanrossum@users.sourceforge.net
2001年10月21日 21:12:46 -0700


Update of /cvsroot/python/python/dist/src/Objects
In directory usw-pr-cvs1:/tmp/cvs-serv15936/Objects
Modified Files:
	abstract.c stringobject.c 
Log Message:
Make the error message for unsupported operand types cleaner, in
response to a message by Laura Creighton on c.l.py. E.g.
 >>> 0+''
 TypeError: unsupported operand types for +: 'int' and 'str'
(previously this did not mention the operand types)
 >>> ''+0
 TypeError: cannot concatenate 'str' and 'int' objects
Index: abstract.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/abstract.c,v
retrieving revision 2.85
retrieving revision 2.86
diff -C2 -d -r2.85 -r2.86
*** abstract.c	2001年10月18日 03:18:43	2.85
--- abstract.c	2001年10月22日 04:12:44	2.86
***************
*** 384,389 ****
 	if (result == Py_NotImplemented) {
 		Py_DECREF(Py_NotImplemented);
! 		PyErr_Format(PyExc_TypeError, 
! 				"unsupported operand type(s) for %s", op_name);
 		return NULL;
 	}
--- 384,393 ----
 	if (result == Py_NotImplemented) {
 		Py_DECREF(Py_NotImplemented);
! 		PyErr_Format(
! 			PyExc_TypeError, 
! 			"unsupported operand type(s) for %s: '%s' and '%s'",
! 			op_name,
! 			v->ob_type->tp_name,
! 			w->ob_type->tp_name);
 		return NULL;
 	}
***************
*** 534,540 ****
 			return x;
 	}
! 	
! 	PyErr_Format(PyExc_TypeError, "unsupported operand type(s) for %s",
! 			op_name);
 	return NULL;
 }
--- 538,557 ----
 			return x;
 	}
! 
! 	if (z == Py_None)
! 		PyErr_Format(
! 			PyExc_TypeError,
! 			"unsupported operand type(s) for ** or pow(): "
! 			"'%s' and '%s'",
! 			v->ob_type->tp_name,
! 			w->ob_type->tp_name);
! 	else
! 		PyErr_Format(
! 			PyExc_TypeError,
! 			"unsupported operand type(s) for pow(): "
! 			"'%s', '%s', '%s'",
! 			v->ob_type->tp_name,
! 			w->ob_type->tp_name,
! 			z->ob_type->tp_name);
 	return NULL;
 }
***************
*** 567,572 ****
 		}
 else {
! PyErr_SetString(PyExc_TypeError,
! "unsupported operand types for +");
 result = NULL;
 }
--- 584,592 ----
 		}
 else {
! PyErr_Format(
! 			 PyExc_TypeError,
! 			 "unsupported operand types for +: '%s' and '%s'",
! 			 v->ob_type->tp_name,
! 			 w->ob_type->tp_name);
 result = NULL;
 }
Index: stringobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/stringobject.c,v
retrieving revision 2.139
retrieving revision 2.140
diff -C2 -d -r2.139 -r2.140
*** stringobject.c	2001年10月16日 20:18:24	2.139
--- stringobject.c	2001年10月22日 04:12:44	2.140
***************
*** 692,696 ****
 #endif
 		PyErr_Format(PyExc_TypeError,
! 			 "cannot add type \"%.200s\" to string",
 			 bb->ob_type->tp_name);
 		return NULL;
--- 692,696 ----
 #endif
 		PyErr_Format(PyExc_TypeError,
! 			 "cannot concatenate 'str' and '%.200s' objects",
 			 bb->ob_type->tp_name);
 		return NULL;

AltStyle によって変換されたページ (->オリジナル) /