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 ezio.melotti, maciej.szulik, martin.panter, orsenthil
Date 2017-03-25.01:01:45
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1490403706.69.0.773089571878.issue29891@psf.upfronthosting.co.za>
In-reply-to
Content
If you enable BytesWarning (python -b) you do get an error:

>>> urlopen(req, data)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.5/urllib/request.py", line 162, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/python3.5/urllib/request.py", line 463, in open
    req = meth(req)
  File "/usr/lib/python3.5/urllib/request.py", line 1171, in do_request_
    if not request.has_header('Content-type'):
  File "/usr/lib/python3.5/urllib/request.py", line 356, in has_header
    return (header_name in self.headers or
BytesWarning: Comparison between bytes and string

I believe the “urllib.request” module is only written with text (str) field names in mind, not byte strings. Same for http.client.HTTPConnection.request(headers=...). But the lower-level HTTPConnection.putheader method has special code to handle byte strings: <http://svn.python.org/view?view=revision&revision=58823>, although this is not documented either.
History
Date User Action Args
2017-03-25 01:01:46martin.pantersetrecipients: + martin.panter, orsenthil, ezio.melotti, maciej.szulik
2017-03-25 01:01:46martin.pantersetmessageid: <1490403706.69.0.773089571878.issue29891@psf.upfronthosting.co.za>
2017-03-25 01:01:46martin.panterlinkissue29891 messages
2017-03-25 01:01:45martin.pantercreate