summaryrefslogtreecommitdiffstats
path: root/Objects/longobject.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1992-08-14 12:06:52 (GMT)
committerGuido van Rossum <guido@python.org>1992-08-14 12:06:52 (GMT)
commite6eefc22313e7f2da5918ecd608fbb0b7a7a1610 (patch)
tree2896ab6358835d67083251ca911ff6d29a1138bf /Objects/longobject.c
parent70d7a310a9844d1a3f80c110f1acd3d6059939b4 (diff)
downloadcpython-e6eefc22313e7f2da5918ecd608fbb0b7a7a1610.zip
cpython-e6eefc22313e7f2da5918ecd608fbb0b7a7a1610.tar.gz
cpython-e6eefc22313e7f2da5918ecd608fbb0b7a7a1610.tar.bz2
* classobject.[ch], {float,long,int}object.c, bltinmodule.c:
coercion is now completely generic. * ceval.c: for instances, don't coerce for + and *; * reverses arguments if left one is non-instance numeric and right one sequence.
Diffstat (limited to 'Objects/longobject.c')
-rw-r--r--Objects/longobject.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/Objects/longobject.c b/Objects/longobject.c
index bf62c1f..f9e3765 100644
--- a/Objects/longobject.c
+++ b/Objects/longobject.c
@@ -1253,6 +1253,19 @@ long_or(a, b)
return long_bitwise(a, '|', b);
}
+int
+long_coerce(pv, pw)
+ object **pv;
+ object **pw;
+{
+ if (is_intobject(*pw)) {
+ *pw = newlongobject(getintvalue(*pw));
+ INCREF(*pv);
+ return 0;
+ }
+ return 1; /* Can't do it */
+}
+
#define UF (object* (*) FPROTO((object *))) /* Unary function */
#define BF (object* (*) FPROTO((object *, object *))) /* Binary function */
#define IF (int (*) FPROTO((object *))) /* Int function */
@@ -1275,6 +1288,8 @@ static number_methods long_as_number = {
BF long_and, /*nb_and*/
BF long_xor, /*nb_xor*/
BF long_or, /*nb_or*/
+ (int (*) FPROTO((object **, object **)))
+ long_coerce, /*nb_coerce*/
};
typeobject Longtype = {