summaryrefslogtreecommitdiff
path: root/cffi/backend_ctypes.py
diff options
context:
space:
mode:
authorArmin Rigo <arigo@tunes.org>2016-09-03 20:10:48 +0200
committerArmin Rigo <arigo@tunes.org>2016-09-03 20:10:48 +0200
commitcdede2fb38671c5b1d5d34871db411749a9efcd2 (patch)
tree71427fd163768e50f76167931733c233d703ac18 /cffi/backend_ctypes.py
parentd114114c36d8ffdb73321b810c8732fefdf80604 (diff)
downloadcffi-cdede2fb38671c5b1d5d34871db411749a9efcd2.tar.gz
fix
Diffstat (limited to 'cffi/backend_ctypes.py')
-rw-r--r--cffi/backend_ctypes.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/cffi/backend_ctypes.py b/cffi/backend_ctypes.py
index ed2e6cd..d160fa7 100644
--- a/cffi/backend_ctypes.py
+++ b/cffi/backend_ctypes.py
@@ -1004,9 +1004,11 @@ class CTypesBackend(object):
import weakref
class MyRef(weakref.ref):
def __eq__(self, other):
- return self() is other()
+ myref = self()
+ return self is other or (
+ myref is not None and myref is other())
def __ne__(self, other):
- return self() is not other()
+ return not (self == other)
self._weakref_cache_ref = {}, MyRef
weak_cache, MyRef = self._weakref_cache_ref