Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Lib/smtplib.py
Original file line number Diff line number Diff line change
Expand Up @@ -1038,7 +1038,7 @@ def _get_socket(self, host, port, timeout):
new_socket = socket.create_connection((host, port), timeout,
self.source_address)
new_socket = self.context.wrap_socket(new_socket,
server_hostname=self._host)
server_hostname=host)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think that the correct way is adding on __init__() the self._host = host

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I don't think so. Cause you make a instance first, the host get "" all the time. I think the best way it's put the "self._host = host" in the connect() function. I'll try for it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I feel like this is probably a better solution than setting _host for the instance. Most of the connect and _get_socket methods take the host and port as input and use that instead of the one defined in the class and from that point-of-view, the use of self._host seems like a bug here.

return new_socket

__all__.append("SMTP_SSL")
Expand Down