Commit a9bad2b
fix(datastructures): MutableScopeHeaders.getall() treats an empty-list default as "no default"
`getall(key, default)` used `if default:` to decide whether a default
was supplied, so an explicit `default=[]` (a legitimate way to ask for
"return an empty list if the header is missing" rather than raising)
is falsy and gets treated the same as `default=None` — raising
KeyError instead of returning `[]`.
Fix: check `if default is not None:` instead, matching the type
signature (`default: list[str] | None = None`) and the pattern already
used elsewhere in this file (e.g. `MutableScopeHeaders.__getitem__`).
How verified: added test_mutable_scope_headers_getall_not_found_empty_list_default,
confirmed it fails with KeyError before the fix and passes after. Full
test_datastructures/ suite (148 tests) passes. mypy and pre-commit
(ruff, unasyncd, typos) clean.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>1 parent 4a43322 commit a9bad2b
2 files changed
Lines changed: 6 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
169 | 169 | | |
170 | 170 | | |
171 | 171 | | |
172 | | - | |
| 172 | + | |
173 | 173 | | |
174 | 174 | | |
175 | 175 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
156 | 156 | | |
157 | 157 | | |
158 | 158 | | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
159 | 164 | | |
160 | 165 | | |
161 | 166 | | |
| |||
0 commit comments