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
smtplib SMTP instances missing a default sock attribute #76861
Comments
SMTP instances from the smtplib module are not creating their sock attribute consistently after __init__ When host is sent as parameter a sock object is created (and hopefully, connected) When the host is not sent, the sock attribute doesn't exist at all |
My use case: try: But I realize just now that in that case, if s was initialized correctly, its sock was inevitably set |
You are right, but... if there is an exception in the connect method before the init of your code will work fine if you use a try/finally but not in the case with SMTP('myhost') as smtp:
smtp.do_something() If there is an exception in the __init__ of SMTP and self.sock is not |
same problem at apple.com |
<a href="apple.com">apple.com</a> |
PR merged for 3.8 branch. I don't think such a simple change deserves a backport for previous Python versions. Closing this out as resolved. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: