Fix so dead ref never equate to being equal. Add __eq__ to py3 version as well.

This commit is contained in:
Matthew Einhorn 2015-06-25 00:25:11 -04:00
parent 9ab759e93a
commit e1f98a46e3
1 changed files with 13 additions and 1 deletions

View File

@ -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