1
0
forked from VimPlug/jedi

__slots__ usage works much better now -> scan for all slots and not only for current class

This commit is contained in:
David Halter
2013-01-09 21:44:59 +01:00
parent f32c2e6dc4
commit e9aadce5ae
2 changed files with 10 additions and 8 deletions

View File

@@ -159,13 +159,15 @@ def fast_parent_copy(obj):
# __dict__ not available, because of __slots__
items = []
before = ()
for cls in new_obj.__class__.__mro__:
try:
names = new_obj.__slots__
if before == cls.__slots__:
continue
before = cls.__slots__
items += [(n, getattr(new_obj, n)) for n in before]
except AttributeError:
# __slots__ not available (normal)
pass
else:
items += [(n, getattr(new_obj, n)) for n in names]
for key, value in items:
# replace parent (first try _parent and then parent)