Fix remove_all_listeners leaving stale empty event key - #209
Merged
jfhbrook merged 2 commits intoAug 13, 2026
Merged
Conversation
remove_all_listeners("event") replaced the event's OrderedDict with an
empty one instead of deleting the key, so the event remained present in
_events and event_names() still reported it as registered. Delete the
key outright (guarded so removing a never-registered event is a no-op
rather than a KeyError) and add regression tests covering both the
single-event and clear-all paths.
Co-Authored-By: Claude <noreply@anthropic.com>
The single-event path is already covered by the fixed assertion at the end of test_listener_removal. Drop the dedicated test_remove_all_listeners_single_event_cleans_key to avoid duplication; keep the clear-all regression test. Co-Authored-By: Claude <noreply@anthropic.com>
Owner
|
Released in v14.0.0. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
EventEmitter.remove_all_listeners("event")replaced the event'sOrderedDictwith an empty one rather than deleting the key:As a result the event key remained present in
_events, andevent_names()kept reporting the event as registered even though it had no listeners. This was inconsistent with_remove_listener, which correctlydels the key when a mapping drains.The fix is deleting the key, the same as
_remove_listener