diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/sugar/dispatch/dispatcher.py | 2 | ||||
-rw-r--r-- | src/sugar/dispatch/saferef.py | 4 |
2 files changed, 6 insertions, 0 deletions
diff --git a/src/sugar/dispatch/dispatcher.py b/src/sugar/dispatch/dispatcher.py index 8fcbe51..c9e1dd1 100644 --- a/src/sugar/dispatch/dispatcher.py +++ b/src/sugar/dispatch/dispatcher.py @@ -8,11 +8,13 @@ from sugar.dispatch import saferef WEAKREF_TYPES = (weakref.ReferenceType, saferef.BoundMethodWeakref) + def _make_id(target): if hasattr(target, 'im_func'): return (id(target.im_self), id(target.im_func)) return id(target) + class Signal(object): """Base class for all signals diff --git a/src/sugar/dispatch/saferef.py b/src/sugar/dispatch/saferef.py index 7c9e1db..b0ceef9 100644 --- a/src/sugar/dispatch/saferef.py +++ b/src/sugar/dispatch/saferef.py @@ -7,6 +7,7 @@ aren't handled by the core weakref module). import weakref, traceback + def safeRef(target, onDelete = None): """Return a *safe* weak reference to a callable target @@ -33,6 +34,7 @@ def safeRef(target, onDelete = None): else: return weakref.ref( target ) + class BoundMethodWeakref(object): """'Safe' and reusable weak references to instance methods @@ -179,6 +181,7 @@ class BoundMethodWeakref(object): return function.__get__(target) return None + class BoundNonDescriptorMethodWeakref(BoundMethodWeakref): """A specialized BoundMethodWeakref, for platforms where instance methods are not descriptors. @@ -239,6 +242,7 @@ class BoundNonDescriptorMethodWeakref(BoundMethodWeakref): return getattr(target, function.__name__) return None + def get_bound_method_weakref(target, onDelete): """Instantiates the appropiate BoundMethodWeakRef, depending on the details of the underlying class method implementation""" |