[docs] [issue22989] HTTPResponse.msg not as documented
Paul Hartmann
report at bugs.python.org
Wed Dec 3 19:45:17 CET 2014
New submission from Paul Hartmann:
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('http://heise.de')
>>> content = req.read()
>>> type(req.msg)
<class 'str'>
>>> req.msg
'OK'
This value is apparently overriden in urllib/request.py:
./urllib/request.py:1246: # This line replaces the .msg attribute of the HTTPResponse
./urllib/request.py-1247- # with .headers, because urllib clients expect the response to
./urllib/request.py:1248: # have the reason in .msg. It would be good to mark this
./urllib/request.py-1249- # attribute is deprecated and get then to use info() or
./urllib/request.py-1250- # .headers.
./urllib/request.py:1251: 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.
[1] https://docs.python.org/3/library/http.client.html
----------
assignee: docs at python
components: Documentation
messages: 232083
nosy: bastik, docs at python
priority: normal
severity: normal
status: open
title: HTTPResponse.msg not as documented
versions: Python 3.4
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue22989>
_______________________________________
More information about the docs
mailing list