This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author serhiy.storchaka
Recipients Oren Milman, mark.dickinson, serhiy.storchaka, vstinner
Date 2017-03-15.09:19:13
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
> If we change something, I suggest to be consistent with lshift. I expect a memory error on "1 << (1 << 1024)" (no unlimited loop before a global system collapse please ;-))

I agree that left shift should raise an ValueError rather than OverflowError for large negative shifts. But is hard to handle large positive shifts. `1 << count` consumes `count*2/15` bytes of memory. There is a gap between the maximal value of bits represented as Py_ssize_t (PY_SSIZE_T_MAX) and the number of bits of maximal Python int (PY_SSIZE_T_MAX*15/2). _PyLong_NumBits() starves from the same issue. I think an OverflowError is appropriate here for denoting the platform and implementation limitation.
Date User Action Args
2017-03-15 09:19:13serhiy.storchakasetrecipients: + serhiy.storchaka, mark.dickinson, vstinner, Oren Milman
2017-03-15 09:19:13serhiy.storchakasetmessageid: <>
2017-03-15 09:19:13serhiy.storchakalinkissue29816 messages
2017-03-15 09:19:13serhiy.storchakacreate