Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork34.2k
gh-145651: Addhttp.client.{HTTPConnection,HTTPResponse}.__repr__#145653
gh-145651: Addhttp.client.{HTTPConnection,HTTPResponse}.__repr__#145653JackDanger wants to merge 5 commits intopython:mainfrom
http.client.{HTTPConnection,HTTPResponse}.__repr__#145653Conversation
python-cla-botbot commentedMar 9, 2026 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
http.client.{HTTPConnection,HTTPResponse}.__repr__Lib/http/client.py Outdated
| self._create_connection = socket.create_connection | ||
| def __repr__(self): | ||
| return '<%s %s:%s>' % (self.__class__.__name__, self.host, self.port if self.port is not None else self.default_port) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Please use an if blockif self.port is None. You can also use f-strings here as it's new code.
Lib/test/test_httplib.py Outdated
| if not hasattr(client, 'HTTPSConnection'): | ||
| self.skipTest('ssl support required') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Use a decorator instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
can do 🙇
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
JackDanger commentedMar 9, 2026
I have made the requested changes; please review again. |
Thanks for making the requested changes! @picnixz: please review the changes made to this pull request. |
Uh oh!
There was an error while loading.Please reload this page.
Add informative
__repr__implementations tohttp.client.HTTPConnectionandhttp.client.HTTPResponse.HTTPConnectionshows host and port:<HTTPConnection example.com:80>HTTPResponseshows status and reason:<HTTPResponse [200 OK]>HTTPSConnectioninherits the repr and shows port 443HTTPResponseshows just<HTTPResponse>before headers are readCloses#145651