Kaydet (Commit) 643d59cb authored tarafından Guido van Rossum's avatar Guido van Rossum

Use a better check for overflow from a<<b.

üst cc8764ca
......@@ -675,13 +675,15 @@ int_lshift(PyIntObject *v, PyIntObject *w)
return NULL;
return PyInt_FromLong(0L);
}
c = (long)((unsigned long)a << b);
if ((c >> b) != a || (c < 0 && a > 0)) {
c = a < 0 ? ~a : a;
c >>= LONG_BIT - 1 - b;
if (c) {
if (PyErr_Warn(PyExc_DeprecationWarning,
"x<<y losing bits or changing sign "
"will return a long in Python 2.4 and up") < 0)
return NULL;
}
c = (long)((unsigned long)a << b);
return PyInt_FromLong(c);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment