Skip to content

Commit fbed0b8

Browse files
committed
fix: tolerate removing unregistered listener (GHSA-5pv9-xcmm-gqc7)
self.listeners is a set, so .remove() raises KeyError, never ValueError — the existing except clause could not catch the only realistic failure mode. Switch to the set-native discard idiom so removing a listener that was never registered (e.g. during teardown / reconnect sequences) no longer breaks the shutdown flow.
1 parent cd765e8 commit fbed0b8

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

src/zeroconf/_handlers/record_manager.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,6 @@ def async_remove_listener(self, listener: RecordUpdateListener) -> None:
214214
215215
This function is not threadsafe and must be called in the eventloop.
216216
"""
217-
try:
218-
self.listeners.remove(listener)
217+
if listener in self.listeners:
218+
self.listeners.discard(listener)
219219
self.zc.async_notify_all()
220-
except ValueError as e:
221-
log.exception("Failed to remove listener: %r", e)

0 commit comments

Comments
 (0)