Issue #27870: A left shift of zero by a large integer no longer attempts to allocate large amounts of memory.
diff --git a/Objects/longobject.c b/Objects/longobject.c
index 6f469bf..de2b139 100644
--- a/Objects/longobject.c
+++ b/Objects/longobject.c
@@ -3715,6 +3715,11 @@
PyErr_SetString(PyExc_ValueError, "negative shift count");
goto lshift_error;
}
+
+ if (Py_SIZE(a) == 0) {
+ return PyLong_FromLong(0);
+ }
+
/* wordshift, remshift = divmod(shiftby, PyLong_SHIFT) */
wordshift = shiftby / PyLong_SHIFT;
remshift = shiftby - wordshift * PyLong_SHIFT;