8000 gh-114552: Update `__dir__` method docs: it allows returning an iterable by sobolevn · Pull Request #114662 · python/cpython · GitHub
[go: up one dir, main page]

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
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Add a test
  • Loading branch information
sobolevn committed Jan 27, 2024
commit 965623e8e15476c47ed177ab2805b2fdc8484404
8 changes: 8 additions & 0 deletions Lib/test/test_builtin.py
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,14 @@ def __dir__(self):
self.assertIsInstance(res, list)
self.assertTrue(res == ["a", "b", "c"])

# dir(obj__dir__iterable)
class Foo(object):
def __dir__(self):
return {"b", "c", "a"}
res = dir(Foo())
self.assertIsInstance(res, list)
self.assertEqual(sorted(res), ["a", "b", "c"])

# dir(obj__dir__not_sequence)
class Foo(object):
def __dir__(self):
Expand Down
0