Skip to content

Commit

Permalink
don't copy __slots__ and properties. also added test
Browse files Browse the repository at this point in the history
  • Loading branch information
colinmarc committed Apr 11, 2012
1 parent a222f4a commit 7be8c5b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
assert mod.Inheritor2().val == 'new'
assert mod.Inheritor3().val == 'new'

assert mod.Slots().prop.val == 'new'

assert mod.user1() == 'new'
assert mod.user2() == 'new'

Expand Down
5 changes: 5 additions & 0 deletions test_orig.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ def __init__(self):
else:
Inheritor3 = Inheritor2

class Slots:
__slots__ = ('prop',)
def __init__(self):
self.prop = Foo()

#methods
def user1():
return Foo().val
Expand Down
3 changes: 2 additions & 1 deletion zodiac.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ def rebase_class(cls, target, new_name=None, ns=None):
new_cls._my_class = new_cls

for name, item in cls.__dict__.items():
if name in ('__dict__', '__bases__', '__weakref__', '__name__', '__module__', '__doc__'): continue
if name in ('__dict__', '__slots__', '__bases__', '__weakref__', '__name__', '__module__', '__doc__'): continue
if isinstance(item, types.MemberDescriptorType): continue
rebase(item, new_cls, name, ns)

setattr(target, new_name, new_cls)
Expand Down

0 comments on commit 7be8c5b

Please sign in to comment.