Skip to content

Docs: Fix some semantic usages of iterator.__iter__ #130172

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 25, 2025

Conversation

koyuki7w
Copy link
Contributor

@koyuki7w koyuki7w commented Feb 16, 2025

The reference to __iter__ method seems to mean object.__iter__, not iterator.__iter__.


📚 Documentation preview 📚: https://cpython-previews--130172.org.readthedocs.build/

The reference to `__iter__` method seems to mean `object.__iter__`, not `iterator.__iter__`.
@bedevere-app bedevere-app bot added docs Documentation in the Doc dir skip news awaiting review labels Feb 16, 2025
Copy link
Member

@picnixz picnixz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the iterator term, we have:

Iterator are required to have an :meth:`~iterator.__iter__` method that returns the iterator

which is correct. Can you check if there are other mentions to iterator.__iter__ when we actually mean object.__iter__?

@picnixz picnixz added needs backport to 3.12 only security fixes needs backport to 3.13 bugs and security fixes skip issue labels Feb 16, 2025
@koyuki7w
Copy link
Contributor Author

glossary.rst has three links to __iter__, and the remaining one refers to iterator.__iter__ correctly.

I also looked for some other files and found some incorrect links in library/abc.rst and library/stdtypes.rst.

@koyuki7w koyuki7w requested a review from picnixz February 16, 2025 14:16
@picnixz picnixz changed the title Docs: Fix incorrect reference in glossary Docs: Fix some semantic usages of iterator.__next__ Feb 16, 2025
@picnixz picnixz changed the title Docs: Fix some semantic usages of iterator.__next__ Docs: Fix some semantic usages of iterator.__iter__ Feb 16, 2025
Copy link
Member

@picnixz picnixz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hope we don't have more __iter__ usages. If you want, you can perhaps look at the other __iter__ usages that were actually iterator.__iter__ and not object.__iter__ or not !__iter__ and vice-versa?

@koyuki7w
Copy link
Contributor Author

__iter__ is used in the following files:

glossary.rst
extending/newtypes.rst
howto/enum.rst
reference/expressions.rst
reference/datamodel.rst
tutorial/classes.rst
library/mailbox.rst
library/abc.rst
library/stdtypes.rst
library/zipfile.rst
library/unittest.rst
library/unittest.mock.rst
library/functions.rst
library/collections.abc.rst
library/unittest.mock-examples.rst

All of these usages are correct except as corrected in this PR.

(Some of them are container.__iter__, which is equivalent to object.__iter__.)

@picnixz picnixz requested a review from AA-Turner February 16, 2025 16:13
@encukou encukou merged commit 4d3a7ea into python:main Feb 25, 2025
28 checks passed
@miss-islington-app
Copy link

Thanks @koyuki7w for the PR, and @encukou for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12, 3.13.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Feb 25, 2025
These references to an `__iter__` method mean `object.__iter__`, not `iterator.__iter__`.
(cherry picked from commit 4d3a7ea)

Co-authored-by: Yuki Kobayashi <[email protected]>
@bedevere-app
Copy link

bedevere-app bot commented Feb 25, 2025

GH-130543 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.13 bugs and security fixes label Feb 25, 2025
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Feb 25, 2025
These references to an `__iter__` method mean `object.__iter__`, not `iterator.__iter__`.
(cherry picked from commit 4d3a7ea)

Co-authored-by: Yuki Kobayashi <[email protected]>
@bedevere-app
Copy link

bedevere-app bot commented Feb 25, 2025

GH-130544 is a backport of this pull request to the 3.12 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.12 only security fixes label Feb 25, 2025
@koyuki7w koyuki7w deleted the doc-fix-1 branch February 25, 2025 13:14
encukou pushed a commit that referenced this pull request Feb 26, 2025
…) (GH-130543)

These references to an `__iter__` method mean `object.__iter__`, not `iterator.__iter__`.
(cherry picked from commit 4d3a7ea)

Co-authored-by: Yuki Kobayashi <[email protected]>
encukou pushed a commit that referenced this pull request Feb 26, 2025
…) (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]>
seehwan pushed a commit to seehwan/cpython that referenced this pull request Apr 16, 2025
These references to an `__iter__` method mean `object.__iter__`, not `iterator.__iter__`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir skip issue skip news
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants