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

aio-libs / multidict / 38125472744
86%

Build:
DEFAULT BRANCH: master
Ran 11 Oct 2026 08:38AM UTC
Jobs 1
Files 50
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

11 Oct 2026 08:37AM UTC coverage: 86.054% (+0.005%) from 86.049%
38125472744

push

github

web-flow
Cap the room reserved for a __length_hint__ (#1767)

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

## What do these changes do?

`extend()`, `update()` and `merge()` in the C extension reserved room
for whatever `__length_hint__()` reported, so a wild hint such as
`2**40` asked for a huge table and raised `MemoryError`. The hint is now
clamped to `USABLE_FRACTION(2**17)`, the largest table `md_init()`
presizes for; the 17 moved into a shared `HT_LOG_MAX_PRESIZE` constant.
The cap applies only to the early reservation: items past it grow the
table as any add does. Exact tuple, list, dict and multidict sizes are
real counts and stay unclamped.

With the hint bounded, the overflow guards added in #1577 only for such
hints (the saturating keyword addition, the early return in
`md_reserve()` and its twin in `md_reserve_batch()`) are dead and were
removed; `htkeys_size_fits()` stays. The pure-Python backend does no
reservation and is unchanged.

## Are there changes in behavior for the user?

Yes: a huge `__length_hint__()` no longer raises `MemoryError`; the
update completes.

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

No. One `Py_MIN()` on the argument parsing path, and less code on the
reserve path.

## 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 (N/A, no documented behaviour
changed)
- [ ] 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); pending review by @asvetlov.

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

`test_huge_length_hint_is_capped` replaces
`test_unallocatable_length_hint_raises_memory_error`; its `2**40` case
raises `MemoryError` on master.
`... (continued)

832 of 1664 branches covered (50.0%)

Branch coverage included in aggregate %.

21 of 24 new or added lines in 1 file covered. (87.5%)

9757 of 10641 relevant lines covered (91.69%)

1.83 hits per line

Uncovered Changes

Lines Coverage ∆ File
3
93.68
-0.03% tests/test_multidict.py
Jobs
ID Job ID Ran Files Coverage
1 MyPy - 38125472744.1 11 Oct 2026 08:38AM UTC 100
86.05
GitHub Action Run
Source Files on build 38125472744
  • Tree
  • List 50
  • 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 #38125472744
  • d6d16d69 on github
  • Prev Build on master (#38118005818)
  • Next Build on master (#38127370395)
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