This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

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 <1538340865.05.0.545547206417.issue34848@psf.upfronthosting.co.za>
In-reply-to
Content
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)
3
>>> [*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.
History
Date User Action Args
2018-09-30 20:54:25bupsetrecipients: + bup, rhettinger, docs@python, serhiy.storchaka
2018-09-30 20:54:25bupsetmessageid: <1538340865.05.0.545547206417.issue34848@psf.upfronthosting.co.za>
2018-09-30 20:54:25buplinkissue34848 messages
2018-09-30 20:54:24bupcreate