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

aio-libs / multidict / 35707035635
87%

Build:
DEFAULT BRANCH: master
Ran 22 Sep 2026 08:51AM UTC
Jobs 1
Files 40
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

22 Sep 2026 08:50AM UTC coverage: 87.749% (-0.008%) from 87.757%
35707035635

push

github

web-flow
Fix del, popall() and getall() walking a table a finalizer changed (#1512)

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

## What do these changes do?

`md_del()` (`del md[key]`) and `md_pop_all()` (`popall()`) cached the
entries pointer before the loop and kept walking the table after each
`_md_del_at()`. That call decrefs the deleted value, and a `__del__`
there can suspend the critical section (or release the GIL), letting
another thread resize the multidict and free the old table. Both
functions now re-check `md->keys` and `md->version` after each deletion
and rescan from the current table when either changed, the same approach
`_md_replace()` already uses.

`md_pop_all()` and `md_get_all()` also used to create the result list
inside the critical section. `PyList_New()` can run a GC (synchronously
before 3.12), and a finalizer there could resize the multidict mid-walk:
`popall()` then deleted through a stale entry pointer and `getall()`
raised a spurious `RuntimeError`. Both functions now take the critical
section themselves, collect strong refs into a small `PyMem`-backed
`reflist_t` while locked, and build the list after unlocking.

This also removes the free-threaded skip from
`test_del_pop_vs_update_same_key_thread_safety`, which was waiting on
this issue. The pure-Python implementation is unaffected.

## Are there changes in behavior for the user?

No, apart from the crash and the spurious `RuntimeError` being gone.

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

No.

## Related issue number

Fixes #1492

## 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` 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); revie... (continued)

762 of 1524 branches covered (50.0%)

Branch coverage included in aggregate %.

20 of 23 new or added lines in 1 file covered. (86.96%)

6730 of 7014 relevant lines covered (95.95%)

1.92 hits per line

Uncovered Changes

Lines Coverage ∆ File
3
93.25
-0.08% tests/test_multidict.py
Jobs
ID Job ID Ran Files Coverage
1 MyPy - 35707035635.1 22 Sep 2026 08:51AM UTC 80
87.75
GitHub Action Run
Source Files on build 35707035635
  • Tree
  • List 40
  • Changed 3
  • Source Changed 1
  • Coverage Changed 3
Coverage ∆ File Lines Relevant Covered Missed Hits/Line Branch Hits Branch Misses
  • Back to Repo
  • Github Actions Build #35707035635
  • a4479a6b on github
  • Prev Build on master (#35703746757)
  • Next Build on master (#35761211686)
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