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@python components: Documentation messages: 232083 nosy: bastik, docs@python priority: normal severity: normal status: open title: HTTPResponse.msg not as documented versions: Python 3.4 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue22989> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com