Author bup
Recipients bup, docs@python, rhettinger, serhiy.storchaka
Date 2018-09-30.20:54:24
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
So I also just happened to notice that the "documentation is wrong" for list, tuple, and collections.deque. They use use _PyEval_SliceIndexNotNone whch causes this:

>>> s = 'abcde'
>>> s.index('d', 0, None)
>>> [*s].index('d', None)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
    [*s].index('d', None)
TypeError: slice indices must be integers or have an __index__ method

In 3.6.0, that error message is:
    TypeError: slice indices must be integers or None or have an __index__ method

which means someone else was aware of this behavior and switched from _PyEval_SliceIndex to _PyEval_SliceIndexNotNone but didn't think these inconsistencies were inappropriate?

Anyway, I'll go ahead fix the docs later for accuracy's sake, but I'd much rather update operator.indexOf to use a new abstract api function: "PySequence_IndexOf" or some such, which is also capable of handling starting from the tail like str.rindex. 

If that's something that could be done, after I finish the Python prototype of this sequence ChainMap analog and rewrite it in C, I'll have made my own abstract sequence index function which I'd happily share.
Date User Action Args
2018-09-30 20:54:25bupsetrecipients: + bup, rhettinger, docs@python, serhiy.storchaka
2018-09-30 20:54:25bupsetmessageid: <>
2018-09-30 20:54:25buplinkissue34848 messages
2018-09-30 20:54:24bupcreate