Skip to content

Commit

Permalink
Make multiplying a sequence by a long integer (5L * 'b') legal
Browse files Browse the repository at this point in the history
  • Loading branch information
akuchling committed Feb 14, 2000
1 parent a46fb38 commit 1991ddc
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions Objects/abstract.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 *");
}
Expand Down

0 comments on commit 1991ddc

Please sign in to comment.