classification
Title: itertools.islice not accepting np.int64
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.6
process
Status: closed Resolution: duplicate
Dependencies: Superseder: Using PyNumber_AsSsize_t in itertools.islice
View: 30537
Assigned To: Nosy List: braaannigan, mark.dickinson, rhettinger, terry.reedy
Priority: normal Keywords:

Created on 2017-08-01 13:23 by braaannigan, last changed 2017-08-05 03:07 by terry.reedy. This issue is now closed.

Messages (6)
msg299617 - (view) Author: LB (braaannigan) Date: 2017-08-01 13:23
The error arises when this code is used:
itertools.islice( [3, 4, 5], np.int64(2) )

but not with this
itertools.islice([3,4,5], 2)
msg299618 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2017-08-01 14:14
See http://bugs.python.org/issue30537
msg299620 - (view) Author: LB (braaannigan) Date: 2017-08-01 15:07
Thanks Ray. The use case is here:
https://stackoverflow.com/questions/45356718/saving-matplotlib-animation-leads-to-error/45438057#45438057

I'm going to suggest a workaround in matplotlib for the moment.  Changing type in this use case shouldn't be a big issue, it only happens once for each animation created.
msg299625 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2017-08-01 17:55
That actually looks as though it may be worth a bug report to the matplotlib folks.
msg299628 - (view) Author: LB (braaannigan) Date: 2017-08-01 18:55
Hi Mark - I've done that here:
https://github.com/matplotlib/matplotlib/issues/8973

Liam
msg299769 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2017-08-05 03:07
LB, an exception is a graceful shutdown, not a crash.  A crash is a seg fault, core dump, or an OS message 'Your app has stopped unexpectedly'.

In #30537, the exception was regarded as expected, not a bug, and changing islice to accept np ints was regarded as an enhancement, and therefore limited to 3.7
History
Date User Action Args
2017-08-05 03:07:56terry.reedysetnosy: + terry.reedy
messages: + msg299769
2017-08-05 03:02:31terry.reedysetstatus: open -> closed
type: crash -> behavior
superseder: Using PyNumber_AsSsize_t in itertools.islice
resolution: duplicate
stage: resolved
2017-08-01 18:55:01braaannigansetmessages: + msg299628
2017-08-01 17:55:57mark.dickinsonsetnosy: + mark.dickinson
messages: + msg299625
2017-08-01 15:07:18braaannigansetmessages: + msg299620
2017-08-01 14:14:53rhettingersetnosy: + rhettinger
messages: + msg299618
2017-08-01 13:23:06braaannigancreate