X Tutup
Skip to content

http.client.HTTPConnection and HTTPResponse are missing __repr__ #145651

@JackDanger

Description

@JackDanger

http.client.HTTPConnection and HTTPResponse lack repr implementations, producing the default unhelpful object repr:

>>> import http.client
>>> http.client.HTTPConnection('example.com')
<http.client.HTTPConnection object at 0x...>

These should show useful state at a glance:

>>> http.client.HTTPConnection('example.com')
<HTTPConnection example.com:80>
>>> http.client.HTTPSConnection('example.com')
<HTTPSConnection example.com:443>

And for responses:

>>> r = conn.getresponse()
>>> r
<HTTPResponse [200 OK]>

The module already has a repr on IncompleteRead, so there's precedent. This would help when debugging HTTP code in the REPL or debugger.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      X Tutup