Issue #18830: inspect.getclasstree() no more produces duplicated entries even

when input list contains duplicates.
This commit is contained in:
Serhiy Storchaka 2013-09-05 17:14:32 +03:00
parent e1040e276b
commit 362c1b513d
4 changed files with 26 additions and 3 deletions

View File

@ -753,7 +753,8 @@ def getclasstree(classes, unique=False):
for parent in c.__bases__:
if not parent in children:
children[parent] = []
children[parent].append(c)
if c not in children[parent]:
children[parent].append(c)
if unique and parent in classes: break
elif c not in roots:
roots.append(c)

View File

@ -49,6 +49,8 @@ class StupidGit:
class MalodorousPervert(StupidGit):
pass
Tit = MalodorousPervert
class ParrotDroppings:
pass

View File

@ -224,8 +224,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,)),

View File

@ -66,6 +66,9 @@ Core and Builtins
Library
-------
- Issue #18830: inspect.getclasstree() no more produces duplicated entries even
when input list contains duplicates.
- Issue #18909: Fix _tkinter.tkapp.interpaddr() on Windows 64-bit, don't cast
64-bit pointer to long (32 bits).