Repository navigation
Name the event and multidict when a watcher callback fails - #1585
Merged
Merged
Conversation
Report a failing callback the way CPython's _PyDict_SendEvent() does: a message naming the event and the multidict's type and address, and no object for sys.unraisablehook to repr(). Previously the multidict itself was passed, so formatting the report could run arbitrary code.
PyErr_FormatUnraisable() formats %p with the platform's printf and only guarantees the 0x prefix, so Windows 3.13+ reports a zero-padded, uppercase address that id() formatting does not match.
asvetlov
marked this pull request as ready for review
September 25, 2026 14:13
Contributor
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1585 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 41 41
Lines 7701 7760 +59
Branches 643 648 +5
=========================================
+ Hits 7701 7760 +59
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
4 of 6 tasks
asvetlov
added a commit
that referenced
this pull request
Sep 25, 2026
<!-- Thank you for your contribution! --> ## What do these changes do? `AGENTS.md` already asked for past-tense news fragments, but an agent still wrote the #1585 fragment as "is now reported ... is now ``None``". This spells out that every verb describing the change is past tense and that the fragment leads with one, names "X is now Y", "X now does Y" and "X will ..." as not past tense, and adds a bad and good example pair taken from #1585. The existing `1310.bugfix.rst` style example also used "is now fixed", so it was rewritten to lead with "Fixed". A matching "Things not to do" bullet was added. ## Are there changes in behavior for the user? No. ## Is it a substantial burden for the maintainers to support this? No; documentation for contributors only. ## Related issue number Related to #1585 ## Checklist - [x] I think the code is well written - [ ] Unit tests for the changes exist: N/A, documentation only - [x] Documentation reflects the changes - [ ] If you provide code modification, please add yourself to `CONTRIBUTORS.txt`: N/A - [x] Add a new news fragment into the `CHANGES/` folder - [x] `make doc-spelling` passes and any new technical words are added to `docs/spelling_wordlist.txt` Drafted with Claude Code (Claude Opus 5.5); reviewed by @asvetlov. <details> <summary>Agent run details (optional, for reviewers)</summary> Spelling: `make doc-spelling` succeeded. Lint: `pre-commit run --files AGENTS.md CHANGES/1588.contrib.rst` passed. </details>
4 of 6 tasks
asvetlov
added a commit
that referenced
this pull request
Sep 26, 2026
<!-- Thank you for your contribution! --> ## What do these changes do? Prepares the news fragments for 7.0.0. The public C API (#1480) and the watchers API (#1551) are new in this release, so the fragments describing later changes to them describe states that never shipped. They are folded into the entries that added the APIs: the visitor's identity and hash (#1552, #1561) into `1478`, and the 32-watcher limit, the watcher registration race fix and the failing-callback report (#1574, #1583, #1585) into `1551`. The `MultiDict_SetDefault(NULL)` half of `1553` is dropped for the same reason. Intermediate header names that never shipped are removed as well: `1510` no longer mentions `deferred_decref.h`, which #1530 merged into `reflist.h`, and `1513` names `debug.h` directly, so `1576` goes. `1572`, a fix to a tool added this cycle, is folded into `1529`. `1560` and the last sentence of `1556` go too, since the release refresh of the benchmark tables supersedes those intermediate ones. Finally, the fragments that did not lead with a past-tense verb or described the change as "now ..." are rewritten per `AGENTS.md`. The benchmark table refresh from `RELEASE.md` step 2 is still to be added to this branch before it leaves draft. ## Are there changes in behavior for the user? No. ## Is it a substantial burden for the maintainers to support this? No. ## Related issue number N/A ## Checklist - [x] I think the code is well written - [ ] Unit tests for the changes exist (N/A, changelog only) - [x] Documentation reflects the changes - [ ] If you provide code modification, please add yourself to `CONTRIBUTORS.txt` (N/A) - [ ] Add a new news fragment into the `CHANGES/` folder (N/A, edits existing fragments; the benchmark refresh will add a `doc` fragment) - [x] `make doc-spelling` passes and any new technical words are added to `docs/spelling_wordlist.txt` Drafted with Claude Code (Claude Opus 5.5); pending review by @asvetlov before leaving draft. <details> <summary>Agent run details (optional, for reviewers)</summary> `python -Im towncrier build --draft --version 7.0.0` renders cleanly. The symlinked pairs `1512` -> `1492` and `1562` -> `1555`, and both `1535` fragments, are intentional and left alone. </details>
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.
What do these changes do?
A failing watcher callback is now reported the way CPython's
_PyDict_SendEvent()reports a failing dict watcher. The message names the event and the multidict's type and address, for exampleException ignored in MultiDict_EVENT_ADDED watcher callback for <multidict._multidict.MultiDict object at 0x...>, and the multidict itself is no longer passed tosys.unraisablehook. Previously every event except DEALLOCATED passed the multidict, so the default hook wouldrepr()it and could run arbitrary code (a subclass__repr__) while an error was being reported.On 3.13+ this uses
PyErr_FormatUnraisable(). On 3.10 to 3.12, which lack it, it uses_PyErr_WriteUnraisableMsg(), and the address is formatted withPRIxPTRbecause MSVC's%pomits the0x. This only affects the C extension: watchers have no pure-Python counterpart.Are there changes in behavior for the user?
Yes, for C API clients whose watcher callbacks fail:
sys.unraisablehooknow receivesobject=Noneand a descriptiveerr_msg.Is it a substantial burden for the maintainers to support this?
No. It is one cold function with a version branch.
Related issue number
Follow-up to #1551.
Checklist
CONTRIBUTORS.txt(N/A)CHANGES/foldermake doc-spellingpasses and any new technical words are added todocs/spelling_wordlist.txtDrafted with Claude Code (Claude Opus 5.5); to be reviewed by @asvetlov.
Agent run details (optional, for reviewers)
Each leg ran in its own venv and tree copy.
MULTIDICT_DEBUG_BUILD=1, Cython harness required: 2866 passed_PyErr_WriteUnraisableMsg()branch): 2734 passed--no-c-extensions: 1286 passedmake doc-spelling: passThis touches
_md_watch_call()inwatch.h, as #1583 does, so whichever lands second needs a small rebase.