mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
[3.12] gh-114552: Update __dir__
method docs: it allows returning an iterable (GH-114662) (#115234)
gh-114552: Update `__dir__` method docs: it allows returning an iterable (GH-114662)
(cherry picked from commit e19103a346
)
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
This commit is contained in:
parent
321ec5e0fe
commit
7cc205872d
2 changed files with 11 additions and 3 deletions
|
@ -586,6 +586,14 @@ class BuiltinTest(unittest.TestCase):
|
|||
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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue