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

aio-libs / multidict / 38259792502
86%

Build:
DEFAULT BRANCH: master
Ran 12 Oct 2026 02:02PM 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

12 Oct 2026 02:00PM UTC coverage: 85.873% (-0.2%) from 86.026%
38259792502

push

github

web-flow
Require the target in the proxies' __new__() (#1782)

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

## What do these changes do?

`MultiDictProxy.__new__(MultiDictProxy)` (and the `CIMultiDictProxy`
equivalent) used `PyType_GenericNew`, so a proxy built without
`__init__()` kept `md == NULL`, and `p.get("k")`, `p["k"]`, `len(p)` or
the C API getters then crashed the interpreter. The proxies got their
own `tp_new`, which allocates and then runs the class's `tp_init`, so
`__new__()` takes the same single argument as the constructor and
rejects a missing or wrong-typed target. No proxy can exist without a
multidict behind it, so the forwarders and the C API need no NULL
checks.

The pure-Python backend got a matching `__new__()`; the target
validation moved into a `_set_target()` helper that `__new__()` and
`__init__()` share, with `CIMultiDictProxy` overriding it.

`tp_new` is `COLD` and calls `tp_init` through a pointer: exact-type
construction always goes through `tp_vectorcall`, so only subclasses and
explicit `__new__()` calls reach it. Without that, inlining
`_multidict_proxy_init()` into the two new functions pushed
`md_get_one()` out of `multidict_mp_subscript()` on 3.11 and out of
`multidict_proxy_mp_subscript()` on 3.14 (`getitem_hit` +7..9% on 3.11).

## Are there changes in behavior for the user?

Yes. `MultiDictProxy.__new__()` and `CIMultiDictProxy.__new__()` require
the proxied multidict instead of returning an object that crashes (C) or
raises `AttributeError` (pure Python) on use. A proxy subclass whose
`__init__()` takes different arguments than the base class now also
needs to override `__new__()`.

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

No; three small functions in the C extension and one helper in the
pure-Python backend.

## Related issue number

N/A, no issue filed.

## Checklist

- [x] I think the code is well written
- [x] Unit tests for the changes exist
- [x] Documentation reflects the changes (N/A, no... (continued)

842 of 1684 branches covered (50.0%)

Branch coverage included in aggregate %.

35 of 54 new or added lines in 3 files covered. (64.81%)

9796 of 10704 relevant lines covered (91.52%)

1.83 hits per line

Uncovered Changes

Lines Coverage ∆ File
15
50.61
0.61% tests/test_types.py
4
73.96
-0.04% tests/test_capi.py
Jobs
ID Job ID Ran Files Coverage
1 MyPy - 38259792502.1 12 Oct 2026 02:02PM UTC 100
85.87
GitHub Action Run
Source Files on build 38259792502
  • Tree
  • List 50
  • Changed 4
  • Source Changed 3
  • Coverage Changed 4
Coverage ∆ File Lines Relevant Covered Missed Hits/Line Branch Hits Branch Misses
  • Back to Repo
  • Github Actions Build #38259792502
  • 16d16a36 on github
  • Prev Build on master (#38255301201)
  • Next Build on master (#38260712021)
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