This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author martin.panter
Recipients Nan Wu, ezio.melotti, martin.panter
Date 2015-10-20.21:04:58
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1445375098.36.0.0909854341878.issue25439@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2015-10-20 21:04:58martin.pantersetrecipients: + martin.panter, ezio.melotti, Nan Wu
2015-10-20 21:04:58martin.pantersetmessageid: <1445375098.36.0.0909854341878.issue25439@psf.upfronthosting.co.za>
2015-10-20 21:04:58martin.panterlinkissue25439 messages
2015-10-20 21:04:58martin.pantercreate