Martin Panter added the comment:
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.
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue25439>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com