summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorAndrew M. Kuchling <amk@amk.ca>2000-02-14 22:22:04 (GMT)
committerAndrew M. Kuchling <amk@amk.ca>2000-02-14 22:22:04 (GMT)
commit1991ddc3e134e89e6c15d60e180fc67ad4c1ca01 (patch)
tree4e9f54179a3203b7a992c3459977a2c2fd63d807 /Objects
parenta46fb3841b71468bdbb613c637b1bc4269829435 (diff)
downloadcpython-1991ddc3e134e89e6c15d60e180fc67ad4c1ca01.zip
cpython-1991ddc3e134e89e6c15d60e180fc67ad4c1ca01.tar.gz
cpython-1991ddc3e134e89e6c15d60e180fc67ad4c1ca01.tar.bz2
Make multiplying a sequence by a long integer (5L * 'b') legal
Diffstat (limited to 'Objects')
-rw-r--r--Objects/abstract.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/Objects/abstract.c b/Objects/abstract.c
index c120769..3fc312a 100644
--- a/Objects/abstract.c
+++ b/Objects/abstract.c
@@ -384,10 +384,21 @@ PyNumber_Multiply(v, w)
}
m = tp->tp_as_sequence;
if (m && m->sq_repeat) {
- if (!PyInt_Check(w))
+ long mul_value;
+
+ if (PyInt_Check(w)) {
+ mul_value = PyInt_AsLong(w);
+ }
+ else if (PyLong_Check(w)) {
+ mul_value = PyLong_AsLong(w);
+ if (PyErr_Occurred())
+ return NULL;
+ }
+ else {
return type_error(
"can't multiply sequence with non-int");
- return (*m->sq_repeat)(v, (int)PyInt_AsLong(w));
+ }
+ return (*m->sq_repeat)(v, (int)mul_value);
}
return type_error("bad operand type(s) for *");
}