Author bastik
Recipients bastik, docs@python
Date 2014-12-03.18:45:17
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
HTTPResponse.msg is documented as a http.client.HTTPMessage object containing the headers of the response [1].

But in fact this is a string containing the status code:

>>> import urllib.request
>>> req=urllib.request.urlopen('')
>>> content =
>>> type(req.msg)
<class 'str'>
>>> req.msg

This value is apparently overriden in urllib/

./urllib/        # This line replaces the .msg attribute of the HTTPResponse
./urllib/        # with .headers, because urllib clients expect the response to
./urllib/        # have the reason in .msg.  It would be good to mark this
./urllib/        # attribute is deprecated and get then to use info() or
./urllib/        # .headers.
./urllib/        r.msg = r.reason

Anyhow, it should be documented, that is not safe to retrieve the headers with HTTPResponse.msg and maybe add HTTPResponse.headers to the documentation.

Date User Action Args
2014-12-03 18:45:17bastiksetrecipients: + bastik, docs@python
2014-12-03 18:45:17bastiksetmessageid: <>
2014-12-03 18:45:17bastiklinkissue22989 messages
2014-12-03 18:45:17bastikcreate