Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-36094: Fix a bug in smtplib module #11998

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion Lib/smtplib.py
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
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
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
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