8000 Clean up both _func_cid_map and callbacks · matplotlib/matplotlib@1411fe2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1411fe2

Browse files
committed
Clean up both _func_cid_map and callbacks
1 parent e7d6f12 commit 1411fe2

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

lib/matplotlib/cbook/__init__.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -216,12 +216,11 @@ def _remove_proxy(self, proxy, *, _is_finalizing=sys.is_finalizing):
216216
if _is_finalizing():
217217
# Weakrefs can't be properly torn down at that point anymore.
218218
return
219-
for signal, proxies in list(self._func_cid_map.items()):
220-
try:
221-
del self.callbacks[signal][proxies[proxy]]
219+
for signal, proxy_to_cid in list(self._func_cid_map.items()):
220+
cid = proxy_to_cid.pop(proxy, None)
221+
if cid is not None:
222+
del self.callbacks[signal][cid]
222223
break
223-
except KeyError:
224-
pass
225224
else:
226225
# Not found
227226
return

lib/matplotlib/tests/test_cbook.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,6 @@ def test_callback_wrong_disconnect(self):
261261
# check we still have callbacks registered
262262
self.is_not_empty()
263263

264-
@pytest.mark.xfail(reason="must be fixed")
265264
def test_registration_on_non_empty_registry(self):
266265
# ensure we start with an empty registry
267266
self.is_empty()

0 commit comments

Comments
 (0)
0