Thanks to visit codestin.com
Credit goes to github.com

Skip to content

gh-114552: Update __dir__ method docs: it allows returning an iterable #114662

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 10, 2024

Conversation

sobolevn
Copy link
Member

@sobolevn sobolevn commented Jan 27, 2024

Copy link
Member

@AlexWaygood AlexWaygood left a comment

Choose a reason for hiding this comment

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

Could you update line 2012 as well? As I noted in #114552 (comment), it seems also to be incorrect

@sobolevn
Copy link
Member Author

sobolevn commented Jan 27, 2024

2012 was a good year :)
Updated.

@AlexWaygood
Copy link
Member

AlexWaygood commented Jan 27, 2024

Do we have any tests that assert that non-sequence iterables are okay to be returned from __dir__ methods? If not, could you add some as part of this PR? :)

Copy link
Member

@AlexWaygood AlexWaygood left a comment

Choose a reason for hiding this comment

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

LGTM, but I'd like for us to wait a little bit before merging, in case anybody else has objections (changing the language spec shouldn't be done lightly, in my opinion)

@terryjreedy terryjreedy added needs backport to 3.11 only security fixes needs backport to 3.12 only security fixes labels Feb 1, 2024
Copy link
Member

@terryjreedy terryjreedy left a comment

Choose a reason for hiding this comment

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

I added the backport labels because I consider this a doc bugfix. The __dir__ doc should have always matched the __dir__ behavior, and indeed they do as long as 'sequence' is properly interpreded. Since the new iterator protocol added the new term 'iterable', an iterable is the obvious requirement. The sloppiness of using 'sequence' when 'iterable' is meant is partly a holdover from the old protocol when only objects with a sequence __getitem__ could be iterated. We are still cleaning up this confusion in the docs.

My perspective is likely colored from having started with 1.3, just before 1.4.

I since read Alex's comment. To me, we are clarifying, not changing, the language spec. I am sure we have made other /sequence/interable/ changes but I cannot remember if they were backported.

@AlexWaygood AlexWaygood merged commit e19103a into python:main Feb 10, 2024
@miss-islington-app
Copy link

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

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Feb 10, 2024
… iterable (pythonGH-114662)

(cherry picked from commit e19103a)

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

bedevere-app bot commented Feb 10, 2024

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

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Feb 10, 2024
… iterable (pythonGH-114662)

(cherry picked from commit e19103a)

Co-authored-by: Nikita Sobolev <[email protected]>
@bedevere-app bedevere-app bot removed the needs backport to 3.12 only security fixes label Feb 10, 2024
@bedevere-app
Copy link

bedevere-app bot commented Feb 10, 2024

GH-115235 is a backport of this pull request to the 3.11 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.11 only security fixes label Feb 10, 2024
AlexWaygood pushed a commit that referenced this pull request Feb 10, 2024
…n iterable (GH-114662) (#115234)

gh-114552: Update `__dir__` method docs: it allows returning an iterable (GH-114662)
(cherry picked from commit e19103a)

Co-authored-by: Nikita Sobolev <[email protected]>
AlexWaygood pushed a commit that referenced this pull request Feb 10, 2024
…n iterable (GH-114662) (#115235)

gh-114552: Update `__dir__` method docs: it allows returning an iterable (GH-114662)
(cherry picked from commit e19103a)

Co-authored-by: Nikita Sobolev <[email protected]>
fsc-eriker pushed a commit to fsc-eriker/cpython that referenced this pull request Feb 14, 2024
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 news
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants