Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f2b332d

Browse files
committed
Cosmetic cleanup by Vladimir.
1 parent 1728942 commit f2b332d

1 file changed

Lines changed: 49 additions & 43 deletions

File tree

Objects/abstract.c

Lines changed: 49 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -654,11 +654,12 @@ PyNumber_InPlaceOr(PyObject *v, PyObject *w)
654654
PyObject *x;
655655

656656
if (PyInstance_Check(v)) {
657-
if (PyInstance_HalfBinOp(v, w, "__ior__", &x, PyNumber_Or,
658-
0) <= 0)
657+
if (PyInstance_HalfBinOp(v, w, "__ior__", &x,
658+
PyNumber_Or, 0) <= 0)
659659
return x;
660-
} else if (v->ob_type->tp_as_number != NULL && HASINPLACE(v) &&
661-
(f = v->ob_type->tp_as_number->nb_inplace_or) != NULL)
660+
}
661+
else if (v->ob_type->tp_as_number != NULL && HASINPLACE(v) &&
662+
(f = v->ob_type->tp_as_number->nb_inplace_or) != NULL)
662663
return (*f)(v, w);
663664

664665
BINOP(v, w, "__or__", "__ror__", PyNumber_Or);
@@ -685,11 +686,12 @@ PyNumber_InPlaceXor(PyObject *v, PyObject *w)
685686
PyObject *x;
686687

687688
if (PyInstance_Check(v)) {
688-
if (PyInstance_HalfBinOp(v, w, "__ixor__", &x, PyNumber_Xor,
689-
0) <= 0)
689+
if (PyInstance_HalfBinOp(v, w, "__ixor__", &x,
690+
PyNumber_Xor, 0) <= 0)
690691
return x;
691-
} else if (v->ob_type->tp_as_number != NULL && HASINPLACE(v) &&
692-
(f = v->ob_type->tp_as_number->nb_inplace_xor) != NULL)
692+
}
693+
else if (v->ob_type->tp_as_number != NULL && HASINPLACE(v) &&
694+
(f = v->ob_type->tp_as_number->nb_inplace_xor) != NULL)
693695
return (*f)(v, w);
694696

695697
BINOP(v, w, "__xor__", "__rxor__", PyNumber_Xor);
@@ -716,11 +718,12 @@ PyNumber_InPlaceAnd(PyObject *v, PyObject *w)
716718
PyObject *x;
717719

718720
if (PyInstance_Check(v)) {
719-
if (PyInstance_HalfBinOp(v, w, "__iand__", &x, PyNumber_And,
720-
0) <= 0)
721+
if (PyInstance_HalfBinOp(v, w, "__iand__", &x,
722+
PyNumber_And, 0) <= 0)
721723
return x;
722-
} else if (v->ob_type->tp_as_number != NULL && HASINPLACE(v) &&
723-
(f = v->ob_type->tp_as_number->nb_inplace_and) != NULL)
724+
}
725+
else if (v->ob_type->tp_as_number != NULL && HASINPLACE(v) &&
726+
(f = v->ob_type->tp_as_number->nb_inplace_and) != NULL)
724727
return (*f)(v, w);
725728

726729
BINOP(v, w, "__and__", "__rand__", PyNumber_And);
@@ -750,8 +753,9 @@ PyNumber_InPlaceLshift(PyObject *v, PyObject *w)
750753
if (PyInstance_HalfBinOp(v, w, "__ilshift__", &x,
751754
PyNumber_Lshift, 0) <= 0)
752755
return x;
753-
} else if (v->ob_type->tp_as_number != NULL && HASINPLACE(v) &&
754-
(f = v->ob_type->tp_as_number->nb_inplace_lshift) != NULL)
756+
}
757+
else if (v->ob_type->tp_as_number != NULL && HASINPLACE(v) &&
758+
(f = v->ob_type->tp_as_number->nb_inplace_lshift) != NULL)
755759
return (*f)(v, w);
756760

757761
BINOP(v, w, "__lshift__", "__rlshift__", PyNumber_Lshift);
@@ -781,8 +785,9 @@ PyNumber_InPlaceRshift(PyObject *v, PyObject *w)
781785
if (PyInstance_HalfBinOp(v, w, "__irshift__", &x,
782786
PyNumber_Rshift, 0) <= 0)
783787
return x;
784-
} else if (v->ob_type->tp_as_number != NULL && HASINPLACE(v) &&
785-
(f = v->ob_type->tp_as_number->nb_inplace_rshift) != NULL)
788+
}
789+
else if (v->ob_type->tp_as_number != NULL && HASINPLACE(v) &&
790+
(f = v->ob_type->tp_as_number->nb_inplace_rshift) != NULL)
786791
return (*f)(v, w);
787792

788793
BINOP(v, w, "__rshift__", "__rrshift__", PyNumber_Rshift);
@@ -856,8 +861,9 @@ PyNumber_InPlaceSubtract(PyObject *v, PyObject *w)
856861
if (PyInstance_HalfBinOp(v, w, "__isub__", &x,
857862
PyNumber_Subtract, 0) <= 0)
858863
return x;
859-
} else if (v->ob_type->tp_as_number != NULL && HASINPLACE(v) &&
860-
(f = v->ob_type->tp_as_number->nb_inplace_subtract) != NULL)
864+
}
865+
else if (v->ob_type->tp_as_number != NULL && HASINPLACE(v) &&
866+
(f = v->ob_type->tp_as_number->nb_inplace_subtract) != NULL)
861867
return (*f)(v, w);
862868

863869
BINOP(v, w, "__sub__", "__rsub__", PyNumber_Subtract);
@@ -881,18 +887,19 @@ PyObject *
881887
PyNumber_InPlaceMultiply(PyObject *v, PyObject *w)
882888
{
883889
PyObject * (*f)(PyObject *, PyObject *) = NULL;
884-
PyObject * (*f2)(PyObject *, int) = NULL;
890+
PyObject * (*g)(PyObject *, int) = NULL;
885891
PyObject *x;
886892

887893
if (PyInstance_Check(v)) {
888894
if (PyInstance_HalfBinOp(v, w, "__imul__", &x,
889895
PyNumber_Multiply, 0) <= 0)
890896
return x;
891-
} else if (v->ob_type->tp_as_number != NULL && HASINPLACE(v) &&
892-
(f = v->ob_type->tp_as_number->nb_inplace_multiply) != NULL)
897+
}
898+
else if (v->ob_type->tp_as_number != NULL && HASINPLACE(v) &&
899+
(f = v->ob_type->tp_as_number->nb_inplace_multiply) != NULL)
893900
return (*f)(v, w);
894901
else if (v->ob_type->tp_as_sequence != NULL && HASINPLACE(v) &&
895-
(f2 = v->ob_type->tp_as_sequence->sq_inplace_repeat) != NULL) {
902+
(g = v->ob_type->tp_as_sequence->sq_inplace_repeat) != NULL) {
896903
long mul_value;
897904

898905
if (PyInt_Check(w)) {
@@ -907,18 +914,11 @@ PyNumber_InPlaceMultiply(PyObject *v, PyObject *w)
907914
return type_error(
908915
"can't multiply sequence with non-int");
909916
}
910-
return (*f2)(v, (int)mul_value);
917+
return (*g)(v, (int)mul_value);
911918
}
919+
912920
BINOP(v, w, "__mul__", "__rmul__", PyNumber_Multiply);
913921

914-
/* if (tp->tp_as_number != NULL &&
915-
w->ob_type->tp_as_sequence != NULL) { */
916-
/* number*sequence -- swap v and w */
917-
/* PyObject *tmp = v;
918-
v = w;
919-
w = tmp;
920-
tp = v->ob_type;
921-
} */
922922
if (v->ob_type->tp_as_number != NULL) {
923923
if (PyNumber_Coerce(&v, &w) != 0)
924924
return NULL;
@@ -929,8 +929,9 @@ PyNumber_InPlaceMultiply(PyObject *v, PyObject *w)
929929
Py_DECREF(w);
930930
if (f != NULL)
931931
return x;
932-
} else if (v->ob_type->tp_as_sequence != NULL &&
933-
(f2 = v->ob_type->tp_as_sequence->sq_repeat) != NULL) {
932+
}
933+
else if (v->ob_type->tp_as_sequence != NULL &&
934+
(g = v->ob_type->tp_as_sequence->sq_repeat) != NULL) {
934935
long mul_value;
935936

936937
if (PyInt_Check(w)) {
@@ -945,7 +946,7 @@ PyNumber_InPlaceMultiply(PyObject *v, PyObject *w)
945946
return type_error(
946947
"can't multiply sequence with non-int");
947948
}
948-
return (*f2)(v, (int)mul_value);
949+
return (*g)(v, (int)mul_value);
949950
}
950951
return type_error("bad operand type(s) for *=");
951952
}
@@ -960,8 +961,9 @@ PyNumber_InPlaceDivide(PyObject *v, PyObject *w)
960961
if (PyInstance_HalfBinOp(v, w, "__idiv__", &x,
961962
PyNumber_Divide, 0) <= 0)
962963
return x;
963-
} else if (v->ob_type->tp_as_number != NULL && HASINPLACE(v) &&
964-
(f = v->ob_type->tp_as_number->nb_inplace_divide) != NULL)
964+
}
965+
else if (v->ob_type->tp_as_number != NULL && HASINPLACE(v) &&
966+
(f = v->ob_type->tp_as_number->nb_inplace_divide) != NULL)
965967
return (*f)(v, w);
966968

967969
BINOP(v, w, "__div__", "__rdiv__", PyNumber_Divide);
@@ -991,8 +993,9 @@ PyNumber_InPlaceRemainder(PyObject *v, PyObject *w)
991993
if (PyInstance_HalfBinOp(v, w, "__imod__", &x,
992994
PyNumber_Remainder, 0) <= 0)
993995
return x;
994-
} else if (v->ob_type->tp_as_number != NULL && HASINPLACE(v) &&
995-
(f = v->ob_type->tp_as_number->nb_inplace_remainder) != NULL)
996+
}
997+
else if (v->ob_type->tp_as_number != NULL && HASINPLACE(v) &&
998+
(f = v->ob_type->tp_as_number->nb_inplace_remainder) != NULL)
996999
return (*f)(v, w);
9971000

9981001
if (PyString_Check(v))
@@ -1028,8 +1031,9 @@ do_inplace_pow(PyObject *v, PyObject *w)
10281031
if (PyInstance_Check(v)) {
10291032
if (PyInstance_HalfBinOp(v, w, "__ipow__", &x, do_pow, 0) <= 0)
10301033
return x;
1031-
} else if (v->ob_type->tp_as_number != NULL && HASINPLACE(v) &&
1032-
(f = v->ob_type->tp_as_number->nb_inplace_power) != NULL)
1034+
}
1035+
else if (v->ob_type->tp_as_number != NULL && HASINPLACE(v) &&
1036+
(f = v->ob_type->tp_as_number->nb_inplace_power) != NULL)
10331037
return (*f)(v, w, Py_None);
10341038

10351039
BINOP(v, w, "__pow__", "__rpow__", do_pow);
@@ -1064,7 +1068,8 @@ PyNumber_InPlacePower(PyObject *v, PyObject *w, PyObject *z)
10641068
if (v->ob_type->tp_as_number == NULL ||
10651069
z->ob_type->tp_as_number == NULL ||
10661070
w->ob_type->tp_as_number == NULL) {
1067-
return type_error("(inplace) pow(x, y, z) requires numeric arguments");
1071+
return type_error(
1072+
"(inplace) pow(x, y, z) requires numeric arguments");
10681073
}
10691074
oldv = v;
10701075
Py_INCREF(oldv);
@@ -1079,15 +1084,16 @@ PyNumber_InPlacePower(PyObject *v, PyObject *w, PyObject *z)
10791084
z2 = z1;
10801085
if (PyNumber_Coerce(&w2, &z2) != 0)
10811086
goto error1;
1082-
if (oldv == v1 && HASINPLACE(v1) && v->ob_type->tp_as_number != NULL &&
1087+
if (oldv == v1 && HASINPLACE(v1) &&
1088+
v->ob_type->tp_as_number != NULL &&
10831089
(f = v1->ob_type->tp_as_number->nb_inplace_power) != NULL)
10841090
res = (*f)(v1, w2, z2);
10851091
else if (v1->ob_type->tp_as_number != NULL &&
10861092
(f = v1->ob_type->tp_as_number->nb_power) != NULL)
10871093
res = (*f)(v1, w2, z2);
10881094
else
10891095
res = type_error(
1090-
"(inplace) pow(x, y, z) not defined for these operands");
1096+
"(inplace) pow(x, y, z) not defined for these operands");
10911097
Py_DECREF(w2);
10921098
Py_DECREF(z2);
10931099
error1:

0 commit comments

Comments
 (0)