-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
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
Conversation
There was a problem hiding this 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
2012 was a good year :) |
Do we have any tests that assert that non-sequence iterables are okay to be returned from |
There was a problem hiding this 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)
There was a problem hiding this 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.
Thanks @sobolevn for the PR, and @AlexWaygood for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11, 3.12. |
… iterable (pythonGH-114662) (cherry picked from commit e19103a) Co-authored-by: Nikita Sobolev <[email protected]>
GH-115234 is a backport of this pull request to the 3.12 branch. |
… iterable (pythonGH-114662) (cherry picked from commit e19103a) Co-authored-by: Nikita Sobolev <[email protected]>
GH-115235 is a backport of this pull request to the 3.11 branch. |
object.__dir__
return a sequence ofstr
, or is any iterable OK? #114552📚 Documentation preview 📚: https://cpython-previews--114662.org.readthedocs.build/