Fix self-extension in MultiDict - #1402
Conversation
Vizonex
left a comment
There was a problem hiding this comment.
@cananoo I like your approach to this but there are some things your going to have to do before you can have my approval on merging this PR.
- 3.14 in the workflows seems to be broken and needs fixing, if you do not have 3.14 my recommendation is to create a virtual environment using the uv package manager system and run
tests/test_multidict.pyusing pytest.
|
I followed up on the 3.14 request. The failing 3.14/3.14t jobs do not report a self-extension assertion failure: they error during pytest-cov teardown because coverage's sysmon core emits On this Windows host I cannot build the C extension because MSVC is unavailable, but I installed the branch in pure-Python mode and ran the requested target: |
|
I followed up on the 3.14 request. The failing 3.14/3.14t jobs do not report a self-extension assertion failure: they error during pytest-cov teardown because coverage's sysmon core emits On this Windows host I cannot build the C extension because MSVC is unavailable, but I installed the branch in pure-Python mode and ran the requested target: I also added a small CI-only follow-up that selects |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1402 +/- ##
=======================================
Coverage 99.86% 99.86%
=======================================
Files 28 28
Lines 3627 3639 +12
Branches 265 268 +3
=======================================
+ Hits 3622 3634 +12
Misses 3 3
Partials 2 2
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:
|
|
The follow-up CI run is complete. All 3.14 and 3.14t extension/non-extension jobs now pass on Linux, macOS, and Windows, including the debug coverage paths. Codecov reports 99.86% project coverage with 100% patch coverage, and CodSpeed reports no performance change. The only remaining red status is Coveralls' project-level report (85.257%, a 0.03% decrease); its patch coverage is 100%, so this appears to be the existing aggregate threshold rather than an uncovered line in this change. The PR is now ready for review. |
|
@Vizonex The requested 3.14/3.14t CI follow-up is complete: all extension and pure-Python jobs pass across Linux, macOS, and Windows. I also marked the PR ready for review. Would you mind taking another look when convenient? |
Confidence Score: 5/5The PR appears safe to merge, with both implementations consistently snapshotting self-alias inputs before mutation. The changed paths preserve entry order, duplicate values, proxy alias behavior, case-insensitive key processing, and temporary-object cleanup, and the parameterized regression test exercises the public self-extension behavior across implementations. Reviews (1): Last reviewed commit: "Fix coverage on Python 3.14 CI" | Re-trigger Greptile |
|
I addressed the Python 3.14 CI issue in |
Vizonex
left a comment
There was a problem hiding this comment.
Great Job, lets see what the others have to say.
What do these changes do?
Make
MultiDict.extendsafe when the source is the destination itself. The C extension and pure Python implementation snapshot the original items before appending, including proxy aliases.Are there changes in behavior for the user?
Yes.
mapping.extend(mapping)now completes and appends exactly one copy of the original entries in their original order.Is it a substantial burden for the maintainers to support this?
No. The change is limited to the existing self-alias paths and regression coverage for both implementations and proxy aliases.
Related issue number
Fixes #1398
Checklist
CONTRIBUTORS.txt(N/A: this repository has noCONTRIBUTORS.txt)CHANGES/folderAgent run details
1662 passed, 7 deselectedMULTIDICT_NO_EXTENSIONS=1self and proxy smoke coverage forMultiDictandCIMultiDict: passedmake doc-spelling: the current tree reports eight existing spelling warnings inCHANGES.rst; the new fragment introduced no spelling warningDrafted with OpenAI Codex (GPT-5); pending human review.