Skip to content
Myr

Don't support broken dict-of-dicts case for data argument (#811)

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 7256366 · Browse files · 2 files+3 added−6 removed
This commit

State

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

Diff stats

2 files+3 added−6 removed

  • tests:+2 added−5 removed
  • other:+1 added−1 removed

2 files+3 added−6 removed

modified:httpx/_content_streams.py+1 added-1 removed
289 unmodified lines
290 def iter_fields(291 self, data: dict, files: dict292 ) -> typing.Iterator[typing.Union["FileField", "DataField"]]:293 for name, value in data.items():294 if isinstance(value, (list, dict)):294 if isinstance(value, list):295 for item in value:296 yield self.DataField(name=name, value=item)297 else:298 yield self.DataField(name=name, value=value)
48 unmodified lines
modified:tests/test_multipart.py+2 added-5 removed
97 unmodified lines
98 data = {99 "a": "1",100 "b": b"C",101 "c": ["11", "22", "33"],102 "d": {"ff": ["1", b"2", "3"], "fff": ["11", b"22", "33"]},103 "f": "",102 "d": "",103 }104 files = {"file": ("name.txt", io.BytesIO(b"<file content>"))}105106 with mock.patch("os.urandom", return_value=os.urandom(16)):
5 unmodified lines
112 '--{0}\r\nContent-Disposition: form-data; name="b"\r\n\r\nC\r\n'113 '--{0}\r\nContent-Disposition: form-data; name="c"\r\n\r\n11\r\n'114 '--{0}\r\nContent-Disposition: form-data; name="c"\r\n\r\n22\r\n'115 '--{0}\r\nContent-Disposition: form-data; name="c"\r\n\r\n33\r\n'117 '--{0}\r\nContent-Disposition: form-data; name="d"\r\n\r\nff\r\n'118 '--{0}\r\nContent-Disposition: form-data; name="d"\r\n\r\nfff\r\n'119 '--{0}\r\nContent-Disposition: form-data; name="f"\r\n\r\n\r\n'116 '--{0}\r\nContent-Disposition: form-data; name="d"\r\n\r\n\r\n'117 '--{0}\r\nContent-Disposition: form-data; name="file";'118 ' filename="name.txt"\r\n'119 "Content-Type: text/plain\r\n\r\n<file content>\r\n"120 "--{0}--\r\n"
78 unmodified lines