Author MSeifert
Recipients MSeifert
Date 2017-06-01.11:26:09
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1496316369.93.0.672552876761.issue30537@psf.upfronthosting.co.za>
In-reply-to
Content
In a question on StackOverflow (https://stackoverflow.com/questions/44302946/itertools-does-not-recognize-numpy-ints-as-valid-inputs-on-python-3-6) 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.`
History
Date User Action Args
2017-06-01 11:26:09MSeifertsetrecipients: + MSeifert
2017-06-01 11:26:09MSeifertsetmessageid: <1496316369.93.0.672552876761.issue30537@psf.upfronthosting.co.za>
2017-06-01 11:26:09MSeifertlinkissue30537 messages
2017-06-01 11:26:09MSeifertcreate