Skip to content
Myr

Raising ValueError's when we're passed inconsistent POST data and files dict.

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

authored by Stephen Huenneke · committed by Stephen Huenneke · parent f75ee9f · Browse files · 2 files+10 added−2 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+10 added−2 removed

  • other:+10 added−2 removed

2 files+10 added−2 removed

modified:requests/models.py+4 added-2 removed
90 unmodified lines
91 2-tuples. Order is retained if data is a list of 2-tuples but abritrary92 if parameters are supplied as a dict.9394 """95 if (not files) or isinstance(data, basestring):96 return None95 if (not files):96 raise ValueError("Files must be provided.")97 elif isinstance(data, basestring):98 raise ValueError("Data must not be a string.")99100 new_fields = []101 fields = to_key_val_list(data or {})102 files = to_key_val_list(files or {})
606 unmodified lines
modified:test_requests.py+6 added
355 unmodified lines
356 requests.post(url, files=['bad file data'])357 except ValueError:358 pass359360 with open('requirements.txt') as f:361 try:362 requests.post(url, data='[{"some": "data"}]', files={'some': f})363 except ValueError:364 pass365366 def test_request_ok_set(self):367 r = requests.get(httpbin('status', '404'))368 self.assertEqual(r.ok, False)369
426 unmodified lines