Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-145651: Addhttp.client.{HTTPConnection,HTTPResponse}.__repr__#145653

Open
JackDanger wants to merge 5 commits intopython:mainfrom
JackDanger:http-client-repr
Open

gh-145651: Addhttp.client.{HTTPConnection,HTTPResponse}.__repr__#145653
JackDanger wants to merge 5 commits intopython:mainfrom
JackDanger:http-client-repr

Conversation

@JackDanger
Copy link

@JackDangerJackDanger commentedMar 9, 2026
edited by bedevere-appbot
Loading

Add informative__repr__ implementations tohttp.client.HTTPConnection andhttp.client.HTTPResponse.

  • HTTPConnection shows host and port:<HTTPConnection example.com:80>
  • HTTPResponse shows status and reason:<HTTPResponse [200 OK]>
  • HTTPSConnection inherits the repr and shows port 443
  • HTTPResponse shows just<HTTPResponse> before headers are read

Closes#145651

@python-cla-bot
Copy link

python-cla-botbot commentedMar 9, 2026
edited
Loading

All commit authors signed the Contributor License Agreement.

CLA signed

@picnixzpicnixz changed the titlegh-145651: Add __repr__ to http.client.HTTPConnection and HTTPResponsegh-145651: Addhttp.client.{HTTPConnection,HTTPResponse}.__repr__Mar 9, 2026
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)
Copy link
Member

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.

Comment on lines +2377 to +2378
if not hasattr(client, 'HTTPSConnection'):
self.skipTest('ssl support required')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Use a decorator instead.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

can do 🙇

@bedevere-app
Copy link

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 phraseI have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@JackDanger
Copy link
Author

I have made the requested changes; please review again.

@bedevere-app
Copy link

Thanks for making the requested changes!

@picnixz: please review the changes made to this pull request.

@bedevere-appbedevere-appbot requested a review frompicnixzMarch 9, 2026 01:03
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@picnixzpicnixzAwaiting requested review from picnixz

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

http.client.HTTPConnection and HTTPResponse are missing __repr__

2 participants

@JackDanger@picnixz

[8]ページ先頭

©2009-2026 Movatter.jp