GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix: tolerate removing unregistered record listener by bluetoothbot · Pull Request #1783 · python-zeroconf/python-zeroconf

Conversation

@bluetoothbot

@bluetoothbot bluetoothbot commented May 26, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

What

Switch RecordManager.async_remove_listener from set.remove() + except ValueError to set.discard(), so removing a listener that was never registered no longer raises.

Why

self.listeners is a set, so .remove(listener) raises KeyError on a missing element — not ValueError. The existing except ValueError clause could not catch the only realistic failure mode of that line, so the documented "log and continue" intent was effectively dead code. A teardown / reconnect path that double-removes a listener propagates KeyError out of Zeroconf.async_remove_listener and breaks the surrounding shutdown.

How

Use set.discard() (the set-native "remove if present" idiom) gated by if listener in self.listeners, so async_notify_all() only fires when something actually changed. The try / except is gone.

Testing

Added tests/test_handlers.py::test_async_remove_listener_missing_does_not_raise in a separate commit against the unfixed code first, so the before/after is explicit. Full suite (SKIP_CYTHON=1 pytest): 393 passed.


Quality Report

Changes: 2 files changed, 16 insertions(+), 4 deletions(-)

Code scan: clean

Tests: passed (4 PASSED)

Branch hygiene: clean

Generated by Kōan post-mission quality pipeline

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
bluetoothbot added 2 commits May 26, 2026 16:54
@bluetoothbot
test: pin async_remove_listener tolerance of unregistered listener
cd765e8
Demonstrates GHSA-5pv9-xcmm-gqc7: set.remove() raises KeyError, which
the except ValueError clause cannot catch.
@bluetoothbot
fix: tolerate removing unregistered listener (GHSA-5pv9-xcmm-gqc7)
fbed0b8
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.
@codecov

codecov Bot commented May 26, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.80%. Comparing base (44433dd) to head (fbed0b8).
⚠️ Report is 4 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1783      +/-   ##
==========================================
+ Coverage   99.77%   99.80%   +0.02%     
==========================================
  Files          33       33              
  Lines        3536     3534       -2     
  Branches      498      499       +1     
==========================================
- Hits         3528     3527       -1     
+ Misses          5        4       -1     
  Partials        3        3              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@codspeed

codspeed Bot commented May 26, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 18 untouched benchmarks


Comparing bluetoothbot:koan/fix-remove-listener-keyerror (fbed0b8) with master (44433dd)

Open in CodSpeed
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bluetoothbot
bluetoothbot temporarily deployed to release May 26, 2026 17:00 — with GitHub Actions Inactive
bdraco
bdraco requested changes May 26, 2026
View reviewed changes

@bdraco bdraco left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should still log debug if listener was never there

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bdraco

bdraco commented May 26, 2026

Copy link
Copy Markdown
Member

@bluetoothbot rr

bluetoothbot reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bluetoothbot

bluetoothbot commented May 26, 2026

Copy link
Copy Markdown
Contributor Author

Rebase with requested adjustments

Branch koan/fix-remove-listener-keyerror was rebased onto master and review feedback was applied.

Stats

2 files changed, 16 insertions(+), 4 deletions(-)
Actions performed
  • Already-solved check: skipped (Claude call failed)
  • Rebased koan/fix-remove-listener-keyerror onto upstream/master
  • Review feedback step failed: Exit code 1: no stderr | stdout: You've hit your session limit · resets 6:30pm (UTC) | stdout: You've hit your session limit · resets 6:30pm (UTC)
  • Pre-push CI check: previous run passed
  • Force-pushed koan/fix-remove-listener-keyerror to origin
  • CI check enqueued in ## CI (async)

CI status

CI will be checked asynchronously.


Automated by Kōan

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bdraco bdraco mentioned this pull request Aug 30, 2026
chore: enforce the declaration ordering convention in ci #1887
Merged
2 tasks done

This branch was previously deployed

1 inactive deployment
release — fbed0b86 Deployed May 26, 2026 by bluetoothbot via release #5479
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@bdraco bdraco bdraco requested changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@bluetoothbot @bdraco
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.