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:28:10 +03:00
parent 930c3c9e43
commit 6db9e88eff
4 changed files with 24 additions and 3 deletions

View File

@ -728,7 +728,8 @@ def getclasstree(classes, unique=0):
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

@ -220,8 +220,23 @@ 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,
[(mod.ParrotDroppings, ()),
[(mod.FesteringGob, (mod.MalodorousPervert,
mod.ParrotDroppings))
],
(mod.StupidGit, ()),
[(mod.MalodorousPervert, (mod.StupidGit,)),
[(mod.FesteringGob, (mod.MalodorousPervert,
mod.ParrotDroppings))
]
]
])
tree = inspect.getclasstree([cls[1] for cls in classes], True)
self.assertEqual(tree,
[(mod.ParrotDroppings, ()),
(mod.StupidGit, ()),

View File

@ -32,6 +32,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).