Issue #18830: inspect.getclasstree() no more produces duplicated entries even
when input list contains duplicates.
This commit is contained in:
commit
1e0d82cece
|
@ -789,6 +789,7 @@ def getclasstree(classes, unique=False):
|
|||
for parent in c.__bases__:
|
||||
if not parent in children:
|
||||
children[parent] = []
|
||||
if c not in children[parent]:
|
||||
children[parent].append(c)
|
||||
if unique and parent in classes: break
|
||||
elif c not in roots:
|
||||
|
|
|
@ -49,6 +49,8 @@ class StupidGit:
|
|||
class MalodorousPervert(StupidGit):
|
||||
pass
|
||||
|
||||
Tit = MalodorousPervert
|
||||
|
||||
class ParrotDroppings:
|
||||
pass
|
||||
|
||||
|
|
|
@ -225,8 +225,25 @@ class TestRetrievingSourceCode(GetSourceBase):
|
|||
[('FesteringGob', mod.FesteringGob),
|
||||
('MalodorousPervert', mod.MalodorousPervert),
|
||||
('ParrotDroppings', mod.ParrotDroppings),
|
||||
('StupidGit', mod.StupidGit)])
|
||||
tree = inspect.getclasstree([cls[1] for cls in classes], 1)
|
||||
('StupidGit', mod.StupidGit),
|
||||
('Tit', mod.MalodorousPervert),
|
||||
])
|
||||
tree = inspect.getclasstree([cls[1] for cls in classes])
|
||||
self.assertEqual(tree,
|
||||
[(object, ()),
|
||||
[(mod.ParrotDroppings, (object,)),
|
||||
[(mod.FesteringGob, (mod.MalodorousPervert,
|
||||
mod.ParrotDroppings))
|
||||
],
|
||||
(mod.StupidGit, (object,)),
|
||||
[(mod.MalodorousPervert, (mod.StupidGit,)),
|
||||
[(mod.FesteringGob, (mod.MalodorousPervert,
|
||||
mod.ParrotDroppings))
|
||||
]
|
||||
]
|
||||
]
|
||||
])
|
||||
tree = inspect.getclasstree([cls[1] for cls in classes], True)
|
||||
self.assertEqual(tree,
|
||||
[(object, ()),
|
||||
[(mod.ParrotDroppings, (object,)),
|
||||
|
|
|
@ -54,6 +54,9 @@ Core and Builtins
|
|||
Library
|
||||
-------
|
||||
|
||||
- Issue #18830: inspect.getclasstree() no more produces duplicated entries even
|
||||
when input list contains duplicates.
|
||||
|
||||
- Issue #18878: sunau.open now supports the context manager protocol. Based on
|
||||
patches by Claudiu Popa and R. David Murray.
|
||||
|
||||
|
|
Loading…
Reference in New Issue