• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

aio-libs / multidict / 34872236619
87%

Build:
DEFAULT BRANCH: master
Ran 14 Sep 2026 05:02PM UTC
Jobs 1
Files 34
Run time 1min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

14 Sep 2026 05:01PM UTC coverage: 86.113% (-0.02%) from 86.131%
34872236619

push

github

web-flow
Fix pure-Python iterator guard missing a mutation before first next() (#1459)

<!-- Thank you for your contribution! -->

## What do these changes do?

Fixes a divergence between the two backends: mutating a
`MultiDict`/`CIMultiDict`
before ever calling `next()` on an `items()`/`keys()`/`values()`
iterator (or on
`iter(md)`) silently raised `StopIteration` in the pure-Python backend
instead of
`RuntimeError`. `_ItemsView._iter`, `_KeysView._iter` and
`_ValuesView._iter`
checked the version *after* pulling an entry out of the `for` loop, so
if the
loop's first pull hit the end immediately (`clear()`, or a
`del`/`popone()` that
removed the last remaining entry) the version check never ran. The fix
checks the
version before pulling the next entry, matching `md_next` in the C
extension,
which already checks `pos->version != md->version` before touching
position or
entries.

## Are there changes in behavior for the user?

Yes. `MultiDict`/`CIMultiDict` iterators from the pure-Python backend
(`MULTIDICT_NO_EXTENSIONS=1`) now correctly raise `RuntimeError` when
the mapping
is mutated before the iterator's first `next()` call, matching the C
extension.

## Is it a substantial burden for the maintainers to support this?

No, it brings the pure-Python backend in line with the
already-documented and
already-tested C extension behavior.

## Related issue number

N/A

## Checklist

- [x] I think the code is well written
- [x] Unit tests for the changes exist
- [x] Documentation reflects the changes
- [ ] If you provide code modification, please add yourself to
`CONTRIBUTORS.txt`
- [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`

<details>
<summary>Agent run details (optional, for reviewers)</summary>

Found while writing new Hypothesis-based fuzz tests for the iterator
guard.

Tests: `pytest -q tests/` (C extension): 1956 passed, 12 skipped.
Tests: `MULTID... (continued)

730 of 1460 branches covered (50.0%)

Branch coverage included in aggregate %.

28 of 31 new or added lines in 2 files covered. (90.32%)

5347 of 5597 relevant lines covered (95.53%)

1.91 hits per line

Uncovered Changes

Lines Coverage ∆ File
3
95.38
-4.62% tests/test_guard.py
Jobs
ID Job ID Ran Files Coverage
1 MyPy - 34872236619.1 14 Sep 2026 05:02PM UTC 68
86.11
GitHub Action Run
Source Files on build 34872236619
  • Tree
  • List 34
  • Changed 3
  • Source Changed 2
  • Coverage Changed 3
Coverage ∆ File Lines Relevant Covered Missed Hits/Line Branch Hits Branch Misses
  • Back to Repo
  • Github Actions Build #34872236619
  • c437773b on github
  • Prev Build on master (#34869375795)
  • Next Build on master (#34934193414)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc