[issue27867] various issues due to misuse of PySlice_GetIndicesEx

Terry J. Reedy report at bugs.python.org
Tue Aug 30 16:40:21 EDT 2016


Terry J. Reedy added the comment:

I like this. Very nice.  What I understand is that callers that access PySlice_GetIndicesEx via the header file (included with Python.h) will see the function as a macro.  When the macro is expanded, the length expression will be evaluated after any __index__ calls.

This approach requires that the length expression calculate the length from the sequence, rather than being a length computer before the call. I checked and all of our users in /Objects pass some form of seq.get_size().  This approach also requires that the function be accessed via .h rather than directly as the function in the .c file.  If we go this way, should he PySlice_GetIndicesEx doc say something?

I reviewed the two new functions and am satisfied a) that they correctly separate converting None and non-ints to ints from adjusting start and stop as ints according to length and b) that the effect of the change in logic for the latter is to stop making unnecessary checks that must fail.

----------

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


More information about the Python-bugs-list mailing list