https://github.com/python/cpython/commit/75358a8e950ad5f3752ae37e04dc8fc2c1557b16 commit: 75358a8e950ad5f3752ae37e04dc8fc2c1557b16 branch: 3.13 author: Miss Islington (bot) <31488909+miss-isling...@users.noreply.github.com> committer: encukou <encu...@gmail.com> date: 2025-02-26T11:02:53+01:00 summary:
[3.13] Docs: Fix some semantic usages of `iterator.__iter__` (GH-130172) (GH-130543) These references to an `__iter__` method mean `object.__iter__`, not `iterator.__iter__`. (cherry picked from commit 4d3a7ea354a8ca7a9978f48e54399526d1b83f42) Co-authored-by: Yuki Kobayashi <drsuaimqj...@gmail.com> files: M Doc/glossary.rst M Doc/library/abc.rst M Doc/library/stdtypes.rst diff --git a/Doc/glossary.rst b/Doc/glossary.rst index 267d8c0793e5be..598f3961a1f321 100644 --- a/Doc/glossary.rst +++ b/Doc/glossary.rst @@ -706,7 +706,7 @@ Glossary iterables include all sequence types (such as :class:`list`, :class:`str`, and :class:`tuple`) and some non-sequence types like :class:`dict`, :term:`file objects <file object>`, and objects of any classes you define - with an :meth:`~iterator.__iter__` method or with a + with an :meth:`~object.__iter__` method or with a :meth:`~object.__getitem__` method that implements :term:`sequence` semantics. diff --git a/Doc/library/abc.rst b/Doc/library/abc.rst index 38d744e97d087d..49e541a9d9b1cb 100644 --- a/Doc/library/abc.rst +++ b/Doc/library/abc.rst @@ -141,18 +141,18 @@ a helper class :class:`ABC` to alternatively define ABCs through inheritance: MyIterable.register(Foo) The ABC ``MyIterable`` defines the standard iterable method, - :meth:`~iterator.__iter__`, as an abstract method. The implementation given + :meth:`~object.__iter__`, as an abstract method. The implementation given here can still be called from subclasses. The :meth:`!get_iterator` method is also part of the ``MyIterable`` abstract base class, but it does not have to be overridden in non-abstract derived classes. The :meth:`__subclasshook__` class method defined here says that any class - that has an :meth:`~iterator.__iter__` method in its + that has an :meth:`~object.__iter__` method in its :attr:`~object.__dict__` (or in that of one of its base classes, accessed via the :attr:`~type.__mro__` list) is considered a ``MyIterable`` too. Finally, the last line makes ``Foo`` a virtual subclass of ``MyIterable``, - even though it does not define an :meth:`~iterator.__iter__` method (it uses + even though it does not define an :meth:`~object.__iter__` method (it uses the old-style iterable protocol, defined in terms of :meth:`~object.__len__` and :meth:`~object.__getitem__`). Note that this will not make ``get_iterator`` available as a method of ``Foo``, so it is provided separately. diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index cb9624ab757330..d910f49ed3a755 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -907,9 +907,9 @@ Generator Types --------------- Python's :term:`generator`\s provide a convenient way to implement the iterator -protocol. If a container object's :meth:`~iterator.__iter__` method is implemented as a +protocol. If a container object's :meth:`~object.__iter__` method is implemented as a generator, it will automatically return an iterator object (technically, a -generator object) supplying the :meth:`!__iter__` and :meth:`~generator.__next__` +generator object) supplying the :meth:`~iterator.__iter__` and :meth:`~generator.__next__` methods. More information about generators can be found in :ref:`the documentation for the yield expression <yieldexpr>`. _______________________________________________ Python-checkins mailing list -- python-checkins@python.org To unsubscribe send an email to python-checkins-le...@python.org https://mail.python.org/mailman3/lists/python-checkins.python.org/ Member address: arch...@mail-archive.com