gh-114552: Update __dir__ method docs: it allows returning an iterable#114662
Conversation
There was a problem hiding this comment.
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 |
terryjreedy
left a comment
There was a problem hiding this comment.
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 <mail@sobolevn.me>
|
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 <mail@sobolevn.me>
|
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/