Issue #27870: A left shift of zero by a large integer no longer attempts to allocate large amounts of memory.

This commit is contained in:
Mark Dickinson 2016-08-29 19:27:06 +01:00
parent 4e1de16f88
commit 82a95277b8
3 changed files with 23 additions and 0 deletions

View file

@ -4281,6 +4281,11 @@ long_lshift(PyObject *v, PyObject *w)
PyErr_SetString(PyExc_ValueError, "negative shift count");
return NULL;
}
if (Py_SIZE(a) == 0) {
return PyLong_FromLong(0);
}
/* wordshift, remshift = divmod(shiftby, PyLong_SHIFT) */
wordshift = shiftby / PyLong_SHIFT;
remshift = shiftby - wordshift * PyLong_SHIFT;