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

aio-libs / multidict / 33997113399
87%

Build:
DEFAULT BRANCH: master
Ran 05 Sep 2026 10:53PM UTC
Jobs 1
Files 31
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

05 Sep 2026 10:52PM UTC coverage: 85.245% (-0.1%) from 85.37%
33997113399

push

github

web-flow
Fix segfault from an uninitialised MultiDict/CIMultiDict created via `__new__` (#1378)

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

## What do these changes do?

`MultiDict.__new__(MultiDict)` (or a subclass that skips
`super().__init__()`) left `md->state` and
`md->keys` as NULL, and the first method call dereferenced them and
segfaulted. The container now has a
`tp_new` that initialises the object to a valid empty state (`state`
set, `keys` = the shared
`&empty_htkeys` sentinel), with `is_ci` derived from the type so
`CIMultiDict` stays case-insensitive.
The sentinel is not heap-allocated, so the `md_init()` that `tp_init`
runs on normal construction does
not leak.

Scope: this fixes the container types. The proxy types
(`MultiDictProxy`/`CIMultiDictProxy`) have the
same latent issue (`self->md` left NULL by `__new__`) but need a
different fix (moving argument
validation into `tp_new`); I'll send that as a follow-up rather than
fold a construction-protocol change
in here. The pure-Python backend raises `AttributeError` for the same
`__new__`-without-`__init__` case
(no crash); aligning it to also yield a valid empty mapping can be a
small follow-up if you'd prefer
exact parity.

## Are there changes in behavior for the user?

Yes (mild): `MultiDict.__new__(MultiDict)` and subclasses that skip
`super().__init__()` now behave as a
valid empty mapping instead of crashing.

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

No. One `tp_new` function shared by both container types.

## Related issue number

Generalises the point fixes #1159 (`setdefault`) and #1161/#1163 (view
types) to the containers.
Surfaced by the analysis report #1306.

## Checklist

- [x] I think the code is well written
- [x] Unit tests for the changes exist
(`test_new_without_init_is_valid_empty`, both container types + a
subclass)
- [x] Documentation reflects the changes (no public API change)
- [ ] N/A — no `CONTRIBUTORS.txt` in this repo
- [x] Add a new news fr... (continued)

627 of 1254 branches covered (50.0%)

Branch coverage included in aggregate %.

11 of 21 new or added lines in 1 file covered. (52.38%)

4099 of 4290 relevant lines covered (95.55%)

1.91 hits per line

Uncovered Changes

Lines Coverage ∆ File
10
90.9
-0.86% tests/test_multidict.py
Jobs
ID Job ID Ran Files Coverage
1 MyPy - 33997113399.1 05 Sep 2026 10:53PM UTC 62
85.25
GitHub Action Run
Source Files on build 33997113399
  • Tree
  • List 31
  • Changed 2
  • Source Changed 1
  • Coverage Changed 2
Coverage ∆ File Lines Relevant Covered Missed Hits/Line Branch Hits Branch Misses
  • Back to Repo
  • Github Actions Build #33997113399
  • b36706a3 on github
  • Prev Build on master (#33996039876)
  • Next Build on master (#34020728891)
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