Kaydet (Commit) 362c1b51 authored tarafından Serhiy Storchaka's avatar Serhiy Storchaka

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

when input list contains duplicates.
üst e1040e27
...@@ -753,7 +753,8 @@ def getclasstree(classes, unique=False): ...@@ -753,7 +753,8 @@ def getclasstree(classes, unique=False):
for parent in c.__bases__: for parent in c.__bases__:
if not parent in children: if not parent in children:
children[parent] = [] children[parent] = []
children[parent].append(c) if c not in children[parent]:
children[parent].append(c)
if unique and parent in classes: break if unique and parent in classes: break
elif c not in roots: elif c not in roots:
roots.append(c) roots.append(c)
......
...@@ -49,6 +49,8 @@ class StupidGit: ...@@ -49,6 +49,8 @@ class StupidGit:
class MalodorousPervert(StupidGit): class MalodorousPervert(StupidGit):
pass pass
Tit = MalodorousPervert
class ParrotDroppings: class ParrotDroppings:
pass pass
......
...@@ -224,8 +224,25 @@ class TestRetrievingSourceCode(GetSourceBase): ...@@ -224,8 +224,25 @@ class TestRetrievingSourceCode(GetSourceBase):
[('FesteringGob', mod.FesteringGob), [('FesteringGob', mod.FesteringGob),
('MalodorousPervert', mod.MalodorousPervert), ('MalodorousPervert', mod.MalodorousPervert),
('ParrotDroppings', mod.ParrotDroppings), ('ParrotDroppings', mod.ParrotDroppings),
('StupidGit', mod.StupidGit)]) ('StupidGit', mod.StupidGit),
tree = inspect.getclasstree([cls[1] for cls in classes], 1) ('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, self.assertEqual(tree,
[(object, ()), [(object, ()),
[(mod.ParrotDroppings, (object,)), [(mod.ParrotDroppings, (object,)),
......
...@@ -66,6 +66,9 @@ Core and Builtins ...@@ -66,6 +66,9 @@ Core and Builtins
Library 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 - Issue #18909: Fix _tkinter.tkapp.interpaddr() on Windows 64-bit, don't cast
64-bit pointer to long (32 bits). 64-bit pointer to long (32 bits).
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment