-
-
Notifications
You must be signed in to change notification settings - Fork 30.5k
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
Conversation
Hello, and thanks for your contribution! I'm a bot set up to make sure that the project can legally accept your contribution by verifying you have signed the PSF contributor agreement (CLA). Our records indicate we have not received your CLA. For legal reasons we need you to sign this before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue. If you have recently signed the CLA, please wait at least one business day You can check yourself to see if the CLA has been received. Thanks again for your contribution, we look forward to reviewing it! |
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.
Good PR, please consider my comment.
Please sign CLA
Lib/smtplib.py
Outdated
@@ -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) |
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.
I think that the correct way is adding on __init__()
the self._host = host
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.
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.
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.
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.
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.
I think it would be better to change the use of self._host
to host
, like the first commit to this PR.
Please also add a NEWS file.
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 |
@Tyrone-Zhao please address the code review from @maxking. Thank you! |
It's October. Is this going to be corrected? Passing host/port at initialization time is unacceptable and unworkable, as the time of configuration is widely divorced from the time of connection, lazily on the first delivery attempt. And repeatedly, as the pool churns through workers and needs to re-connect when reaching pipelining limits. The next major will issue a warning on any SMTP use, as a deprecated interface, but that's ancillary. |
This update was made to meet 2 needs: - Bug Fix: python#11998 - Allow backward compatibility with Python 2.7.9 or higher.
Bug Fix: python#11998
Bug Fix: python#11998
The following bug occurs when you connect after creating an instance of SMTP_SSL:
ValueError:
server_hostname cannot be an empty string or start with a leading dot.
File "E:\code\noUse.py", line 8, in
con2.connect(smtp_server, 465)
https://bugs.python.org/issue36094