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 MSeifert
Recipients MSeifert
Date 2017-06-01.11:26:09
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
In a question on StackOverflow ( it was mentioned that numpys scalars cannot be used as index for `itertools.islice`. 

The reason for this is because the numbers are converted with `PyLong_AsSsize_t` (which requires a PyLongObject [or subclass]) instead of `PyNumber_AsSsize_t` (which only requires an `__index__` method).

I'm not sure if there are many use-cases where numpy scalars make sense as inputs for `islice` but it's definetly unexpected that `itertools.islice([1, 2, 3, 4, 5, 6], np.int32(3))` currently throws a `ValueError: Stop argument for islice() must be None or an integer: 0 <= x <= sys.maxsize.`
Date User Action Args
2017-06-01 11:26:09MSeifertsetrecipients: + MSeifert
2017-06-01 11:26:09MSeifertsetmessageid: <>
2017-06-01 11:26:09MSeifertlinkissue30537 messages
2017-06-01 11:26:09MSeifertcreate