Wrapper similar to a weakref, but keeping a strong reference to the object.
| 117 | |
| 118 | |
| 119 | class _StrongRef: |
| 120 | """ |
| 121 | Wrapper similar to a weakref, but keeping a strong reference to the object. |
| 122 | """ |
| 123 | |
| 124 | def __init__(self, obj): |
| 125 | self._obj = obj |
| 126 | |
| 127 | def __call__(self): |
| 128 | return self._obj |
| 129 | |
| 130 | def __eq__(self, other): |
| 131 | return isinstance(other, _StrongRef) and self._obj == other._obj |
| 132 | |
| 133 | def __hash__(self): |
| 134 | return hash(self._obj) |
| 135 | |
| 136 | |
| 137 | def _weak_or_strong_ref(func, callback): |
no outgoing calls
no test coverage detected
searching dependent graphs…