Skip to content
Myr

Better handling of invalid files.

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

I stole the idea from _encode_params in all candor.

authored by Ian Cordasco · committed by Ian Cordasco · parent 1efd06a · Browse files · 2 files+12 added−0 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+12 added−0 removed

  • tests:+5 added−0 removed
  • other:+7 added−0 removed

2 files+12 added−0 removed

modified:requests/models.py+7 added
340 unmodified lines
341342 try:343 fields = list(self.data.items())344 except AttributeError:345 dict(self.data)346 fields = list(self.data)347348 try:349 dict(files)350 except ValueError:351 raise ValueError('Unable to encode lists with elements that '352 'are not 2-tuples.')353354 if isinstance(files, dict):355 files = files.items()356357 for (k, v) in files:
498 unmodified lines
modified:tests/test_requests.py+5 added
318 unmodified lines
319320 post4 = post(url, data='[{"some": "json"}]')321 self.assertEqual(post4.status_code, 200)322323 try:324 post(url, files=['bad file data'])325 except ValueError:326 pass327328 def test_POSTBIN_GET_POST_FILES_WITH_PARAMS(self):329330 for service in SERVICES:331
697 unmodified lines