diff options
author | Guido van Rossum <guido@python.org> | 2000-09-01 23:27:32 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2000-09-01 23:27:32 (GMT) |
commit | bb8be93a50b0293b812634575a493c4eaf676773 (patch) | |
tree | ade11e0a9727b9faa9f4c17e28693f70093d5004 | |
parent | 46981de633c25bf18733420d1f4692506cce4c74 (diff) | |
download | cpython-bb8be93a50b0293b812634575a493c4eaf676773.zip cpython-bb8be93a50b0293b812634575a493c4eaf676773.tar.gz cpython-bb8be93a50b0293b812634575a493c4eaf676773.tar.bz2 |
Rewritten some pieces of PyNumber_InPlaceAdd() for clarity.
-rw-r--r-- | Objects/abstract.c | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/Objects/abstract.c b/Objects/abstract.c index 4e9ed96..ef3064b 100644 --- a/Objects/abstract.c +++ b/Objects/abstract.c @@ -810,28 +810,33 @@ PyNumber_InPlaceAdd(PyObject *v, PyObject *w) if (PyInstance_Check(v)) { if (PyInstance_HalfBinOp(v, w, "__iadd__", &x, - PyNumber_Add, 0) <= 0) + PyNumber_Add, 0) <= 0) return x; } - else if (HASINPLACE(v) - && ((v->ob_type->tp_as_sequence != NULL && - (f = v->ob_type->tp_as_sequence->sq_inplace_concat) - != NULL) - || (v->ob_type->tp_as_number != NULL && - (f = v->ob_type->tp_as_number->nb_inplace_add) != NULL))) - return (*f)(v, w); + else if (HASINPLACE(v)) { + if (v->ob_type->tp_as_sequence != NULL) + f = v->ob_type->tp_as_sequence->sq_inplace_concat; + if (f == NULL && v->ob_type->tp_as_number != NULL) + f = v->ob_type->tp_as_number->nb_inplace_add; + if (f != NULL) + return (*f)(v, w); + } BINOP(v, w, "__add__", "__radd__", PyNumber_Add); - if (v->ob_type->tp_as_sequence != NULL && - (f = v->ob_type->tp_as_sequence->sq_concat) != NULL) - return (*f)(v, w); - else if (v->ob_type->tp_as_number != NULL) { + if (v->ob_type->tp_as_sequence != NULL) { + f = v->ob_type->tp_as_sequence->sq_concat; + if (f != NULL) + return (*f)(v, w); + } + if (v->ob_type->tp_as_number != NULL) { if (PyNumber_Coerce(&v, &w) != 0) return NULL; - if (v->ob_type->tp_as_number != NULL && - (f = v->ob_type->tp_as_number->nb_add) != NULL) - x = (*f)(v, w); + if (v->ob_type->tp_as_number != NULL) { + f = v->ob_type->tp_as_number->nb_add; + if (f != NULL) + x = (*f)(v, w); + } Py_DECREF(v); Py_DECREF(w); if (f != NULL) |