mirror of
https://github.com/python/cpython.git
synced 2025-11-02 19:12:55 +00:00
GH-101100: Fix reference warnings for `__getitem__` (#110118)
This commit is contained in:
parent
d144749914
commit
da99133710
20 changed files with 38 additions and 38 deletions
|
|
@ -1058,7 +1058,7 @@ subject value:
|
|||
.. note:: Key-value pairs are matched using the two-argument form of the mapping
|
||||
subject's ``get()`` method. Matched key-value pairs must already be present
|
||||
in the mapping, and not created on-the-fly via :meth:`__missing__` or
|
||||
:meth:`__getitem__`.
|
||||
:meth:`~object.__getitem__`.
|
||||
|
||||
In simple terms ``{KEY1: P1, KEY2: P2, ... }`` matches only if all the following
|
||||
happens:
|
||||
|
|
|
|||
|
|
@ -889,7 +889,7 @@ to the index so that, for example, ``x[-1]`` selects the last item of ``x``. The
|
|||
resulting value must be a nonnegative integer less than the number of items in
|
||||
the sequence, and the subscription selects the item whose index is that value
|
||||
(counting from zero). Since the support for negative indices and slicing
|
||||
occurs in the object's :meth:`__getitem__` method, subclasses overriding
|
||||
occurs in the object's :meth:`~object.__getitem__` method, subclasses overriding
|
||||
this method will need to explicitly add that support.
|
||||
|
||||
.. index::
|
||||
|
|
@ -944,7 +944,7 @@ slice list contains no proper slice).
|
|||
single: step (slice object attribute)
|
||||
|
||||
The semantics for a slicing are as follows. The primary is indexed (using the
|
||||
same :meth:`__getitem__` method as
|
||||
same :meth:`~object.__getitem__` method as
|
||||
normal subscription) with a key that is constructed from the slice list, as
|
||||
follows. If the slice list contains at least one comma, the key is a tuple
|
||||
containing the conversion of the slice items; otherwise, the conversion of the
|
||||
|
|
@ -1670,7 +1670,7 @@ If an exception is raised during the iteration, it is as if :keyword:`in` raised
|
|||
that exception.
|
||||
|
||||
Lastly, the old-style iteration protocol is tried: if a class defines
|
||||
:meth:`__getitem__`, ``x in y`` is ``True`` if and only if there is a non-negative
|
||||
:meth:`~object.__getitem__`, ``x in y`` is ``True`` if and only if there is a non-negative
|
||||
integer index *i* such that ``x is y[i] or x == y[i]``, and no lower integer index
|
||||
raises the :exc:`IndexError` exception. (If any other exception is raised, it is as
|
||||
if :keyword:`in` raised that exception).
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue