Skip to content

Commit 7575abb

Browse files
[3.12] Docs: Fix some semantic usages of iterator.__iter__ (GH-130172) (GH-130544)
These references to an `__iter__` method mean `object.__iter__`, not `iterator.__iter__`. (cherry picked from commit 4d3a7ea) Co-authored-by: Yuki Kobayashi <[email protected]>
1 parent f841099 commit 7575abb

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

Doc/glossary.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ Glossary
656656
iterables include all sequence types (such as :class:`list`, :class:`str`,
657657
and :class:`tuple`) and some non-sequence types like :class:`dict`,
658658
:term:`file objects <file object>`, and objects of any classes you define
659-
with an :meth:`~iterator.__iter__` method or with a
659+
with an :meth:`~object.__iter__` method or with a
660660
:meth:`~object.__getitem__` method
661661
that implements :term:`sequence` semantics.
662662

Doc/library/abc.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,18 +141,18 @@ a helper class :class:`ABC` to alternatively define ABCs through inheritance:
141141
MyIterable.register(Foo)
142142

143143
The ABC ``MyIterable`` defines the standard iterable method,
144-
:meth:`~iterator.__iter__`, as an abstract method. The implementation given
144+
:meth:`~object.__iter__`, as an abstract method. The implementation given
145145
here can still be called from subclasses. The :meth:`!get_iterator` method
146146
is also part of the ``MyIterable`` abstract base class, but it does not have
147147
to be overridden in non-abstract derived classes.
148148

149149
The :meth:`__subclasshook__` class method defined here says that any class
150-
that has an :meth:`~iterator.__iter__` method in its
150+
that has an :meth:`~object.__iter__` method in its
151151
:attr:`~object.__dict__` (or in that of one of its base classes, accessed
152152
via the :attr:`~type.__mro__` list) is considered a ``MyIterable`` too.
153153

154154
Finally, the last line makes ``Foo`` a virtual subclass of ``MyIterable``,
155-
even though it does not define an :meth:`~iterator.__iter__` method (it uses
155+
even though it does not define an :meth:`~object.__iter__` method (it uses
156156
the old-style iterable protocol, defined in terms of :meth:`~object.__len__` and
157157
:meth:`~object.__getitem__`). Note that this will not make ``get_iterator``
158158
available as a method of ``Foo``, so it is provided separately.

Doc/library/stdtypes.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -907,9 +907,9 @@ Generator Types
907907
---------------
908908

909909
Python's :term:`generator`\s provide a convenient way to implement the iterator
910-
protocol. If a container object's :meth:`~iterator.__iter__` method is implemented as a
910+
protocol. If a container object's :meth:`~object.__iter__` method is implemented as a
911911
generator, it will automatically return an iterator object (technically, a
912-
generator object) supplying the :meth:`!__iter__` and :meth:`~generator.__next__`
912+
generator object) supplying the :meth:`~iterator.__iter__` and :meth:`~generator.__next__`
913913
methods.
914914
More information about generators can be found in :ref:`the documentation for
915915
the yield expression <yieldexpr>`.

0 commit comments

Comments
 (0)