8000 Clean up dicts the same way with _remove_proxy or disconnect · matplotlib/matplotlib@ab10d45 · GitHub
[go: up one dir, main page]

Skip to content

Commit ab10d45

Browse files
committed
Clean up dicts the same way with _remove_proxy or disconnect
1 parent 1411fe2 commit ab10d45

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

lib/matplotlib/cbook/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ def _remove_proxy(self, proxy, *, _is_finalizing=sys.is_finalizing):
224224
else:
225225
# Not found
226226
return
227+
# Clean up empty dicts
227228
if len(self.callbacks[signal]) == 0:
228229
del self.callbacks[signal]
229230
del self._func_cid_map[signal]
@@ -248,6 +249,10 @@ def disconnect(self, cid):
248249
if current_cid == cid:
249250
assert proxy is current_proxy
250251
del proxy_to_cid[current_proxy]
252+
# Clean up empty dicts
253+
if len(self.callbacks[signal]) == 0:
254+
del self.callbacks[signal]
255+
del self._func_cid_map[signal]
251256

252257
def process(self, s, *args, **kwargs):
253258
"""

lib/matplotlib/tests/test_cbook.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,6 @@ def test_callback_complete(self):
226226
# check we now have no callbacks registered
227227
self.is_empty()
228228

229-
@pytest.mark.xfail(reason="must be fixed")
230229
def test_callback_disconnect(self):
231230
# ensure we start with an empty registry
232231
self.is_empty()

0 commit comments

Comments
 (0)
0