mirror of https://github.com/kivy/kivy.git
Fix so dead ref never equate to being equal. Add __eq__ to py3 version as well.
This commit is contained in:
parent
9ab759e93a
commit
e1f98a46e3
|
@ -55,6 +55,15 @@ if sys.version > '3':
|
|||
'''
|
||||
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)
|
||||
|
@ -107,7 +116,10 @@ else:
|
|||
|
||||
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
|
||||
|
||||
|
|
Loading…
Reference in New Issue