enthought / enthought/envisage
Fix evil global dictionary of ExtensionPointBinding instances.
- Dominant language
- Python
- Stars
- 89
- Forks
- 27
- Avg merge
- 14h 48m
- Merged PRs (30d)
- 7
Description
The `ExtensionPointBinding` class keeps a record of all its instances in a `WeakKeyDictionary` class attribute:
```python
class ExtensionPointBinding(HasTraits):
""" A binding between a trait on an object and an extension point. """
#### 'ExtensionPointBinding' *CLASS* interface ############################
# We keep a reference to each binding alive until its associated object
# is garbage collected.
_bindings = weakref.WeakKeyDictionary()
...
```
This makes it awkward to use in unit tests, where it's easy to end up with the values in the `WeakKeyDictionary` keeping objects alive at the end of the test. It would be good to have a clean, documented way to avoid this problem.
In the specific issue that prompted this bug report, we had an `Application` object with extension point bindings that themselves contained references back to the `Application` object. That meant that after setting up the application and then tearing it back down again, the entire `Application` was still alive by virtue of being referred to by a value in the `_bindings` dictionary above.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.