Skip to content
Myr

Fix empty query params (#2354)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Tom Christie · committed by GitHub · parent 3eee17e · Browse files · 2 files+12 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Trailers

  • Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>

Diff stats

2 files+12 added−1 removed

  • tests:+11 added−0 removed
  • other:+1 added−1 removed

2 files+12 added−1 removed

modified:httpx/_urls.py+1 added-1 removed
538 unmodified lines
539540 items: typing.Sequence[typing.Tuple[str, PrimitiveData]]541 if value is None or isinstance(value, (str, bytes)):542 value = value.decode("ascii") if isinstance(value, bytes) else value543 self._dict = parse_qs(value)543 self._dict = parse_qs(value, keep_blank_values=True)544 elif isinstance(value, QueryParams):545 self._dict = {k: list(v) for k, v in value._dict.items()}546 else:547 dict_value: typing.Dict[typing.Any, typing.List[typing.Any]] = {}
204 unmodified lines
modified:tests/models/test_queryparams.py+11 added
74 unmodified lines
75 q = httpx.QueryParams({"a": [1, 2]})76 assert str(q) == "a=1&a=2"777879def test_empty_query_params():80 q = httpx.QueryParams({"a": ""})81 assert str(q) == "a="8283 q = httpx.QueryParams("a=")84 assert str(q) == "a="8586 q = httpx.QueryParams("a")87 assert str(q) == "a="888990def test_queryparam_update_is_hard_deprecated():91 q = httpx.QueryParams("a=123")92 with pytest.raises(RuntimeError):93 q.update({"a": "456"})
43 unmodified lines