Rewritten some pieces of PyNumber_InPlaceAdd() for clarity.
This commit is contained in:
parent
46981de633
commit
bb8be93a50
|
@ -810,28 +810,33 @@ PyNumber_InPlaceAdd(PyObject *v, PyObject *w)
|
||||||
|
|
||||||
if (PyInstance_Check(v)) {
|
if (PyInstance_Check(v)) {
|
||||||
if (PyInstance_HalfBinOp(v, w, "__iadd__", &x,
|
if (PyInstance_HalfBinOp(v, w, "__iadd__", &x,
|
||||||
PyNumber_Add, 0) <= 0)
|
PyNumber_Add, 0) <= 0)
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
else if (HASINPLACE(v)
|
else if (HASINPLACE(v)) {
|
||||||
&& ((v->ob_type->tp_as_sequence != NULL &&
|
if (v->ob_type->tp_as_sequence != NULL)
|
||||||
(f = v->ob_type->tp_as_sequence->sq_inplace_concat)
|
f = v->ob_type->tp_as_sequence->sq_inplace_concat;
|
||||||
!= NULL)
|
if (f == NULL && v->ob_type->tp_as_number != NULL)
|
||||||
|| (v->ob_type->tp_as_number != NULL &&
|
f = v->ob_type->tp_as_number->nb_inplace_add;
|
||||||
(f = v->ob_type->tp_as_number->nb_inplace_add) != NULL)))
|
if (f != NULL)
|
||||||
return (*f)(v, w);
|
return (*f)(v, w);
|
||||||
|
}
|
||||||
|
|
||||||
BINOP(v, w, "__add__", "__radd__", PyNumber_Add);
|
BINOP(v, w, "__add__", "__radd__", PyNumber_Add);
|
||||||
|
|
||||||
if (v->ob_type->tp_as_sequence != NULL &&
|
if (v->ob_type->tp_as_sequence != NULL) {
|
||||||
(f = v->ob_type->tp_as_sequence->sq_concat) != NULL)
|
f = v->ob_type->tp_as_sequence->sq_concat;
|
||||||
return (*f)(v, w);
|
if (f != NULL)
|
||||||
else if (v->ob_type->tp_as_number != NULL) {
|
return (*f)(v, w);
|
||||||
|
}
|
||||||
|
if (v->ob_type->tp_as_number != NULL) {
|
||||||
if (PyNumber_Coerce(&v, &w) != 0)
|
if (PyNumber_Coerce(&v, &w) != 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
if (v->ob_type->tp_as_number != NULL &&
|
if (v->ob_type->tp_as_number != NULL) {
|
||||||
(f = v->ob_type->tp_as_number->nb_add) != NULL)
|
f = v->ob_type->tp_as_number->nb_add;
|
||||||
x = (*f)(v, w);
|
if (f != NULL)
|
||||||
|
x = (*f)(v, w);
|
||||||
|
}
|
||||||
Py_DECREF(v);
|
Py_DECREF(v);
|
||||||
Py_DECREF(w);
|
Py_DECREF(w);
|
||||||
if (f != NULL)
|
if (f != NULL)
|
||||||
|
|
Loading…
Reference in New Issue