diff options
author | Jeremy Hylton <jeremy@alum.mit.edu> | 2002-03-08 21:11:37 (GMT) |
---|---|---|
committer | Jeremy Hylton <jeremy@alum.mit.edu> | 2002-03-08 21:11:37 (GMT) |
commit | 6ae6a43a77e3170cc952d182b67533b560eb6dbe (patch) | |
tree | 2dba62bf2b5dd4e1ce63ff45ca45375469819ffd /Objects/abstract.c | |
parent | 8acf1e0e01a841183e61e63bf956494a0517ceed (diff) | |
download | cpython-6ae6a43a77e3170cc952d182b67533b560eb6dbe.zip cpython-6ae6a43a77e3170cc952d182b67533b560eb6dbe.tar.gz cpython-6ae6a43a77e3170cc952d182b67533b560eb6dbe.tar.bz2 |
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.
Diffstat (limited to 'Objects/abstract.c')
-rw-r--r-- | Objects/abstract.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/Objects/abstract.c b/Objects/abstract.c index 2acfd08..2207602 100644 --- a/Objects/abstract.c +++ b/Objects/abstract.c @@ -605,11 +605,10 @@ PyNumber_Add(PyObject *v, PyObject *w) PyObject *result = binary_op1(v, w, NB_SLOT(nb_add)); if (result == Py_NotImplemented) { PySequenceMethods *m = v->ob_type->tp_as_sequence; - Py_DECREF(Py_NotImplemented); - if (m && m->sq_concat) { + Py_DECREF(result); + if (m && m->sq_concat) result = (*m->sq_concat)(v, w); - } - else { + if (result == Py_NotImplemented) { PyErr_Format( PyExc_TypeError, "unsupported operand types for +: '%s' and '%s'", |