[issue27867] various issues due to misuse of PySlice_GetIndicesEx

Terry J. Reedy report at bugs.python.org
Fri Aug 26 15:21:04 EDT 2016


Terry J. Reedy added the comment:

I presume you are suggesting to raise if the length changes.  This is similar to raising when a dict is mutated while iterating.  Note that we do not do this with mutable sequences.  (If the iteration is stopped with out-of-memory error, so be it.)

An alternate approach would be to first fully evaluate start, stop, step , *and then length*, to ints, in that order, before using any of them.  In particular, have everything stable before comparing and adjusting start and stop to length.  This way, slices would continue to always work, barring other exceptions in __index__ or __length__.

----------
nosy: +terry.reedy

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue27867>
_______________________________________


More information about the Python-bugs-list mailing list