bpo-36094: Fix a bug in smtplib module#11998
bpo-36094: Fix a bug in smtplib module#11998Tyrone-Zhao wants to merge 2 commits intopython:masterfrom Tyrone-Zhao:fix-issue-36999
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! |
eamanu
left a comment
There was a problem hiding this comment.
Good PR, please consider my comment.
Please sign CLA
Lib/smtplib.py
Outdated
| 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.
I think that the correct way is adding on __init__() the self._host = host
There was a problem hiding this comment.
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.
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.
maxking
left a comment
There was a problem hiding this comment.
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