From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Thu, 21 Dec 2023 22:01:25 +0000 (+0100) Subject: [3.11] gh-113313: Note that slice support is not required for all sequences. (gh... X-Git-Tag: v3.11.8~237 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=beb1c6506c8ff77ddc73f763e94122640f0feb8d;p=thirdparty%2FPython%2Fcpython.git [3.11] gh-113313: Note that slice support is not required for all sequences. (gh-113377) (gh-113383) --- diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst index 4f25579cbcfb..1c2324d77cd4 100644 --- a/Doc/reference/datamodel.rst +++ b/Doc/reference/datamodel.rst @@ -2782,9 +2782,9 @@ through the object's keys; for sequences, it should iterate through the values. .. method:: object.__getitem__(self, key) Called to implement evaluation of ``self[key]``. For :term:`sequence` types, - the accepted keys should be integers and slice objects. Note that the - special interpretation of negative indexes (if the class wishes to emulate a - :term:`sequence` type) is up to the :meth:`__getitem__` method. If *key* is + the accepted keys should be integers. Optionally, they may support + :class:`slice` objects as well. Negative index support is also optional. + If *key* is of an inappropriate type, :exc:`TypeError` may be raised; if *key* is a value outside the set of indexes for the sequence (after any special interpretation of negative values), :exc:`IndexError` should be raised. For