Message253252
The iterable option is documented under the urlopen(data=...) parameter, albeit not under the Request.data attribute. IMO this isn’t right, because you need to use Request to add Content-Length, but that is a separate documentation issue.
Technically, an empty dict() and a dictionary of bytes keys are both iterables of bytes. I admit it is a strange case though; this is one of those canned worms I mentioned. Example:
headers = {"Content-Length": 6}
data = OrderedDict(((b"abc", 1), (b"def", 2))))
urlopen(Request("http://localhost/", headers=headers, data=data))
# Sends request data b"abcdef"
Using the annotate function <https://hg.python.org/cpython/annotate/0a0aafaa9bf5/Lib/test/test_urllib.py#l1167> reveals that your empty dict() tests were added by revision 0a0aafaa9bf5. I suspect it was an accident that happened to work, which is really an argument for diagnosing passing in a dict, although as I mentioned this is technically breaking compatibility. |
|
Date |
User |
Action |
Args |
2015-10-20 21:04:58 | martin.panter | set | recipients:
+ martin.panter, ezio.melotti, Nan Wu |
2015-10-20 21:04:58 | martin.panter | set | messageid: <1445375098.36.0.0909854341878.issue25439@psf.upfronthosting.co.za> |
2015-10-20 21:04:58 | martin.panter | link | issue25439 messages |
2015-10-20 21:04:58 | martin.panter | create | |
|