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 crickert
Recipients crickert
Date 2015-11-06.20:39:12
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
A piece of software stopped working after the update from Python 3.4.x to 3.5 (both Linux and Windows).

I found the cause in the  Request.add_header("abcd","efgh")  function:
If the first parameter string "abcd" contains a colon (":") character, a ValueError is raised and the execution stops.

This is an example code:

>>> import urllib.request
>>> import urllib.parse
>>> data = urllib.parse.urlencode({'spam': 1, 'eggs': 2, 'bacon': 0})
>>> data = data.encode('utf-8')
>>> request = urllib.request.Request("")
>>> # adding charset parameter to the Content-Type header.
>>> request.add_header("Content-Type:","application/x-www-form-urlencoded;charset=utf-8")
>>> with urllib.request.urlopen(request, data) as f:
...     print('utf-8'))

This is the error:

Traceback (most recent call last):
  File "C:\Users\user\Desktop\", line 9, in <module>
    with urllib.request.urlopen(request, data) as f:
  File "C:\python\lib\urllib\", line 162, in urlopen
    return, data, timeout)
  File "C:\python\lib\urllib\", line 465, in open
    response = self._open(req, data)
  File "C:\python\lib\urllib\", line 483, in _open
    '_open', req)
  File "C:\python\lib\urllib\", line 443, in _call_chain
    result = func(*args)
  File "C:\python\lib\urllib\", line 1268, in http_open
    return self.do_open(http.client.HTTPConnection, req)
  File "C:\python\lib\urllib\", line 1240, in do_open
    h.request(req.get_method(), req.selector,, headers)
  File "C:\python\lib\http\", line 1083, in request
    self._send_request(method, url, body, headers)
  File "C:\python\lib\http\", line 1123, in _send_request
    self.putheader(hdr, value)
  File "C:\python\lib\http\", line 1050, in putheader
    raise ValueError('Invalid header name %r' % (header,))
ValueError: Invalid header name b'Content-Type:'

Steps to reproduce:

Add a colon character anywhere into the first parameter of the  Request.add_header()  function and execute the code using Python 3.5.x.
Date User Action Args
2015-11-06 20:39:12crickertsetrecipients: + crickert
2015-11-06 20:39:12crickertsetmessageid: <>
2015-11-06 20:39:12crickertlinkissue25570 messages
2015-11-06 20:39:12crickertcreate