classification
Title: Implement `http.client.HTTPMessage.__repr__` to make debugging easier
Type: enhancement Stage: patch review
Components: email, Library (Lib) Versions: Python 3.9
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: ZackerySpytz, barry, cool-RR, demian.brecht, martin.panter, r.david.murray
Priority: normal Keywords: patch

Created on 2015-05-31 10:38 by cool-RR, last changed 2020-02-13 18:24 by demian.brecht.

Pull Requests
URL Status Linked Edit
PR 18127 open ZackerySpytz, 2020-01-22 20:21
Messages (4)
msg244536 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2015-05-31 11:23
HTTPMessage essentially has exactly the same functionality as email.message.Message. It has been suggested to replace it with an alias to the Message class; see Issue 5053. So perhaps it would be best to add __repr__() to the underlying Message class instead?

What information do you think should be included? The whole tostring() value? Specific header fields, such as Content-Type?
msg244537 - (view) Author: Ram Rachum (cool-RR) * Date: 2015-05-31 11:25
Regarding a unified `__repr__`: Sounds good. What I needed is to know whether there are any headers in there or not. So the number of headers, or the first 2-3, would have solved my problem.
msg275068 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2016-09-08 17:12
I would suggest something like:

  <email.message.Message instance at 0xXXXXXXX with NN headers and MM MIME parts>
  <email.message.Message instance at 0xXXXXXXX with NN headers and MM body lines>

The second case should be rare these days for email, but would (I think?) show 0 body lines for an HTTPMessage.  If I'm right it might actually make sense to have a separate repr for HTTPMessage that omitted the body line count.
msg360504 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2020-01-22 20:49
Thanks for the PR, but I've noted an issue on the review.  In any case we should agree on what goes in the repr here in this issue before actually implementing anything.
History
Date User Action Args
2020-02-13 18:24:12demian.brechtsetnosy: + demian.brecht
2020-01-22 20:49:24r.david.murraysetmessages: + msg360504
2020-01-22 20:22:35ZackerySpytzsetnosy: + ZackerySpytz

versions: + Python 3.9, - Python 3.5
2020-01-22 20:21:09ZackerySpytzsetkeywords: + patch
stage: patch review
pull_requests: + pull_request17514
2016-09-08 17:12:42r.david.murraysetmessages: + msg275068
2015-05-31 11:25:19cool-RRsetmessages: + msg244537
2015-05-31 11:23:29martin.pantersetnosy: + barry, r.david.murray, martin.panter
messages: + msg244536
components: + email
2015-05-31 10:38:14cool-RRcreate