Skip to content

Commit

Permalink
Fix so dead ref never equate to being equal. Add __eq__ to py3 versio…
Browse files Browse the repository at this point in the history
…n as well.
  • Loading branch information
matham committed Jun 25, 2015
1 parent 9ab759e commit e1f98a4
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion kivy/weakmethod.py
Expand Up @@ -55,6 +55,15 @@ def is_dead(self):
'''
return self.proxy is not None and not bool(dir(self.proxy))

def __eq__(self, other):
try:
if type(self) is not type(other):
return False
s = self()
return s is not None and s == other()
except:
return False

def __repr__(self):
return '<WeakMethod proxy={} method={} method_name={}>'.format(
self.proxy, self.method, self.method_name)
Expand Down Expand Up @@ -107,7 +116,10 @@ def is_dead(self):

def __eq__(self, other):
try:
return type(self) is type(other) and self() == other()
if type(self) is not type(other):
return False
s = self()
return s is not None and s == other()
except:
return False

Expand Down

0 comments on commit e1f98a4

Please sign in to comment.