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.

Title: HTTPResponse.msg not as documented
Type: Stage: resolved
Components: Documentation Versions: Python 3.6, Python 3.4, Python 3.5
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: bastik, docs@python, martin.panter, python-dev, r.david.murray
Priority: normal Keywords:

Created on 2014-12-03 18:45 by bastik, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (5)
msg232083 - (view) Author: (bastik) Date: 2014-12-03 18:45
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.

msg232224 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2014-12-05 22:51
See Issue 21228 for a patch which documents the “.msg” hack, and that the info() method is available for HTTP responses.

I think documenting the “.headers” attribute would be a bad idea, because it is introducing yet another way to do what the almost-documented info() method already does.
msg234943 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2015-01-29 03:59
Documenting the “headers” attribute is also discussed in Issue 12707
msg255406 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2015-11-26 11:07
New changeset fa3c9faabfb0 by Martin Panter in branch '3.4':
Issues #22989, #21228: Document HTTP response object for urlopen()

New changeset b55c006b79bc by Martin Panter in branch '3.5':
Issue #22989, #21228: Merge urlopen() doc from 3.4 into 3.5

New changeset c6930661599b by Martin Panter in branch 'default':
Issue #22989, #21228: Merge urlopen() doc from 3.5
msg255408 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2015-11-26 11:19
The documentation now mentions the “msg” quirk and the info() method.
Date User Action Args
2022-04-11 14:58:10adminsetgithub: 67178
2015-11-26 11:19:03martin.pantersetstatus: open -> closed
versions: + Python 3.5, Python 3.6
messages: + msg255408

resolution: fixed
stage: resolved
2015-11-26 11:07:15python-devsetnosy: + python-dev
messages: + msg255406
2015-01-29 03:59:05martin.pantersetmessages: + msg234943
2014-12-05 22:51:03martin.pantersetnosy: + martin.panter
messages: + msg232224
2014-12-03 18:56:51r.david.murraysetnosy: + r.david.murray
2014-12-03 18:45:17bastikcreate