[Python-checkins] CVS: python/dist/src/Objects abstract.c,2.53,2.54
Thomas Wouters
python-dev@python.org
Sat, 2 Sep 2000 01:34:43 -0700
Update of /cvsroot/python/python/dist/src/Objects
In directory slayer.i.sourceforge.net:/tmp/cvs-serv30096/Objects
Modified Files:
abstract.c
Log Message:
Cosmetic cleanup by Vladimir.
Index: abstract.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/abstract.c,v
retrieving revision 2.53
retrieving revision 2.54
diff -C2 -r2.53 -r2.54
*** abstract.c 2000/09/01 23:27:32 2.53
--- abstract.c 2000/09/02 08:34:40 2.54
***************
*** 655,663 ****
if (PyInstance_Check(v)) {
! if (PyInstance_HalfBinOp(v, w, "__ior__", &x, PyNumber_Or,
! 0) <= 0)
return x;
! } else if (v->ob_type->tp_as_number != NULL && HASINPLACE(v) &&
! (f = v->ob_type->tp_as_number->nb_inplace_or) != NULL)
return (*f)(v, w);
--- 655,664 ----
if (PyInstance_Check(v)) {
! if (PyInstance_HalfBinOp(v, w, "__ior__", &x,
! PyNumber_Or, 0) <= 0)
return x;
! }
! else if (v->ob_type->tp_as_number != NULL && HASINPLACE(v) &&
! (f = v->ob_type->tp_as_number->nb_inplace_or) != NULL)
return (*f)(v, w);
***************
*** 686,694 ****
if (PyInstance_Check(v)) {
! if (PyInstance_HalfBinOp(v, w, "__ixor__", &x, PyNumber_Xor,
! 0) <= 0)
return x;
! } else if (v->ob_type->tp_as_number != NULL && HASINPLACE(v) &&
! (f = v->ob_type->tp_as_number->nb_inplace_xor) != NULL)
return (*f)(v, w);
--- 687,696 ----
if (PyInstance_Check(v)) {
! if (PyInstance_HalfBinOp(v, w, "__ixor__", &x,
! PyNumber_Xor, 0) <= 0)
return x;
! }
! else if (v->ob_type->tp_as_number != NULL && HASINPLACE(v) &&
! (f = v->ob_type->tp_as_number->nb_inplace_xor) != NULL)
return (*f)(v, w);
***************
*** 717,725 ****
if (PyInstance_Check(v)) {
! if (PyInstance_HalfBinOp(v, w, "__iand__", &x, PyNumber_And,
! 0) <= 0)
return x;
! } else if (v->ob_type->tp_as_number != NULL && HASINPLACE(v) &&
! (f = v->ob_type->tp_as_number->nb_inplace_and) != NULL)
return (*f)(v, w);
--- 719,728 ----
if (PyInstance_Check(v)) {
! if (PyInstance_HalfBinOp(v, w, "__iand__", &x,
! PyNumber_And, 0) <= 0)
return x;
! }
! else if (v->ob_type->tp_as_number != NULL && HASINPLACE(v) &&
! (f = v->ob_type->tp_as_number->nb_inplace_and) != NULL)
return (*f)(v, w);
***************
*** 751,756 ****
PyNumber_Lshift, 0) <= 0)
return x;
! } else if (v->ob_type->tp_as_number != NULL && HASINPLACE(v) &&
! (f = v->ob_type->tp_as_number->nb_inplace_lshift) != NULL)
return (*f)(v, w);
--- 754,760 ----
PyNumber_Lshift, 0) <= 0)
return x;
! }
! else if (v->ob_type->tp_as_number != NULL && HASINPLACE(v) &&
! (f = v->ob_type->tp_as_number->nb_inplace_lshift) != NULL)
return (*f)(v, w);
***************
*** 782,787 ****
PyNumber_Rshift, 0) <= 0)
return x;
! } else if (v->ob_type->tp_as_number != NULL && HASINPLACE(v) &&
! (f = v->ob_type->tp_as_number->nb_inplace_rshift) != NULL)
return (*f)(v, w);
--- 786,792 ----
PyNumber_Rshift, 0) <= 0)
return x;
! }
! else if (v->ob_type->tp_as_number != NULL && HASINPLACE(v) &&
! (f = v->ob_type->tp_as_number->nb_inplace_rshift) != NULL)
return (*f)(v, w);
***************
*** 857,862 ****
PyNumber_Subtract, 0) <= 0)
return x;
! } else if (v->ob_type->tp_as_number != NULL && HASINPLACE(v) &&
! (f = v->ob_type->tp_as_number->nb_inplace_subtract) != NULL)
return (*f)(v, w);
--- 862,868 ----
PyNumber_Subtract, 0) <= 0)
return x;
! }
! else if (v->ob_type->tp_as_number != NULL && HASINPLACE(v) &&
! (f = v->ob_type->tp_as_number->nb_inplace_subtract) != NULL)
return (*f)(v, w);
***************
*** 882,886 ****
{
PyObject * (*f)(PyObject *, PyObject *) = NULL;
! PyObject * (*f2)(PyObject *, int) = NULL;
PyObject *x;
--- 888,892 ----
{
PyObject * (*f)(PyObject *, PyObject *) = NULL;
! PyObject * (*g)(PyObject *, int) = NULL;
PyObject *x;
***************
*** 889,897 ****
PyNumber_Multiply, 0) <= 0)
return x;
! } else if (v->ob_type->tp_as_number != NULL && HASINPLACE(v) &&
! (f = v->ob_type->tp_as_number->nb_inplace_multiply) != NULL)
return (*f)(v, w);
else if (v->ob_type->tp_as_sequence != NULL && HASINPLACE(v) &&
! (f2 = v->ob_type->tp_as_sequence->sq_inplace_repeat) != NULL) {
long mul_value;
--- 895,904 ----
PyNumber_Multiply, 0) <= 0)
return x;
! }
! else if (v->ob_type->tp_as_number != NULL && HASINPLACE(v) &&
! (f = v->ob_type->tp_as_number->nb_inplace_multiply) != NULL)
return (*f)(v, w);
else if (v->ob_type->tp_as_sequence != NULL && HASINPLACE(v) &&
! (g = v->ob_type->tp_as_sequence->sq_inplace_repeat) != NULL) {
long mul_value;
***************
*** 908,923 ****
"can't multiply sequence with non-int");
}
! return (*f2)(v, (int)mul_value);
}
BINOP(v, w, "__mul__", "__rmul__", PyNumber_Multiply);
- /* if (tp->tp_as_number != NULL &&
- w->ob_type->tp_as_sequence != NULL) { */
- /* number*sequence -- swap v and w */
- /* PyObject *tmp = v;
- v = w;
- w = tmp;
- tp = v->ob_type;
- } */
if (v->ob_type->tp_as_number != NULL) {
if (PyNumber_Coerce(&v, &w) != 0)
--- 915,923 ----
"can't multiply sequence with non-int");
}
! return (*g)(v, (int)mul_value);
}
+
BINOP(v, w, "__mul__", "__rmul__", PyNumber_Multiply);
if (v->ob_type->tp_as_number != NULL) {
if (PyNumber_Coerce(&v, &w) != 0)
***************
*** 930,935 ****
if (f != NULL)
return x;
! } else if (v->ob_type->tp_as_sequence != NULL &&
! (f2 = v->ob_type->tp_as_sequence->sq_repeat) != NULL) {
long mul_value;
--- 930,936 ----
if (f != NULL)
return x;
! }
! else if (v->ob_type->tp_as_sequence != NULL &&
! (g = v->ob_type->tp_as_sequence->sq_repeat) != NULL) {
long mul_value;
***************
*** 946,950 ****
"can't multiply sequence with non-int");
}
! return (*f2)(v, (int)mul_value);
}
return type_error("bad operand type(s) for *=");
--- 947,951 ----
"can't multiply sequence with non-int");
}
! return (*g)(v, (int)mul_value);
}
return type_error("bad operand type(s) for *=");
***************
*** 961,966 ****
PyNumber_Divide, 0) <= 0)
return x;
! } else if (v->ob_type->tp_as_number != NULL && HASINPLACE(v) &&
! (f = v->ob_type->tp_as_number->nb_inplace_divide) != NULL)
return (*f)(v, w);
--- 962,968 ----
PyNumber_Divide, 0) <= 0)
return x;
! }
! else if (v->ob_type->tp_as_number != NULL && HASINPLACE(v) &&
! (f = v->ob_type->tp_as_number->nb_inplace_divide) != NULL)
return (*f)(v, w);
***************
*** 992,997 ****
PyNumber_Remainder, 0) <= 0)
return x;
! } else if (v->ob_type->tp_as_number != NULL && HASINPLACE(v) &&
! (f = v->ob_type->tp_as_number->nb_inplace_remainder) != NULL)
return (*f)(v, w);
--- 994,1000 ----
PyNumber_Remainder, 0) <= 0)
return x;
! }
! else if (v->ob_type->tp_as_number != NULL && HASINPLACE(v) &&
! (f = v->ob_type->tp_as_number->nb_inplace_remainder) != NULL)
return (*f)(v, w);
***************
*** 1029,1034 ****
if (PyInstance_HalfBinOp(v, w, "__ipow__", &x, do_pow, 0) <= 0)
return x;
! } else if (v->ob_type->tp_as_number != NULL && HASINPLACE(v) &&
! (f = v->ob_type->tp_as_number->nb_inplace_power) != NULL)
return (*f)(v, w, Py_None);
--- 1032,1038 ----
if (PyInstance_HalfBinOp(v, w, "__ipow__", &x, do_pow, 0) <= 0)
return x;
! }
! else if (v->ob_type->tp_as_number != NULL && HASINPLACE(v) &&
! (f = v->ob_type->tp_as_number->nb_inplace_power) != NULL)
return (*f)(v, w, Py_None);
***************
*** 1065,1069 ****
z->ob_type->tp_as_number == NULL ||
w->ob_type->tp_as_number == NULL) {
! return type_error("(inplace) pow(x, y, z) requires numeric arguments");
}
oldv = v;
--- 1069,1074 ----
z->ob_type->tp_as_number == NULL ||
w->ob_type->tp_as_number == NULL) {
! return type_error(
! "(inplace) pow(x, y, z) requires numeric arguments");
}
oldv = v;
***************
*** 1080,1084 ****
if (PyNumber_Coerce(&w2, &z2) != 0)
goto error1;
! if (oldv == v1 && HASINPLACE(v1) && v->ob_type->tp_as_number != NULL &&
(f = v1->ob_type->tp_as_number->nb_inplace_power) != NULL)
res = (*f)(v1, w2, z2);
--- 1085,1090 ----
if (PyNumber_Coerce(&w2, &z2) != 0)
goto error1;
! if (oldv == v1 && HASINPLACE(v1) &&
! v->ob_type->tp_as_number != NULL &&
(f = v1->ob_type->tp_as_number->nb_inplace_power) != NULL)
res = (*f)(v1, w2, z2);
***************
*** 1088,1092 ****
else
res = type_error(
! "(inplace) pow(x, y, z) not defined for these operands");
Py_DECREF(w2);
Py_DECREF(z2);
--- 1094,1098 ----
else
res = type_error(
! "(inplace) pow(x, y, z) not defined for these operands");
Py_DECREF(w2);
Py_DECREF(z2);