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
This commit is contained in:
Guido van Rossum 2001-10-22 04:12:44 +00:00
parent 279e744573
commit 5c66a26dee
2 changed files with 28 additions and 8 deletions

View file

@ -691,7 +691,7 @@ string_concat(register PyStringObject *a, register PyObject *bb)
return PyUnicode_Concat((PyObject *)a, bb);
#endif
PyErr_Format(PyExc_TypeError,
"cannot add type \"%.200s\" to string",
"cannot concatenate 'str' and '%.200s' objects",
bb->ob_type->tp_name);
return NULL;
}