-
-
Notifications
You must be signed in to change notification settings - Fork 29.4k
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
Bug in smtplib example #120662
Comments
Please can you link to the relevant page? |
The proper idiom would be to make an initialized list of lines, append further lines, and join with '\r\n' when complete.
|
Well... PEP 8 is a suggestion, not a requirement so it can't force people to follow it. For the rest, it's probably because at the time when it was written, f-strings and context managers did not exist and the code has not been updated since then.
To ensure that you don't have whitespaces before and after in the list of mails to send to, just before the
that's a good question; I think it was assumed that you only want to send a single paragraph (though I agree it's not really a good idea since you could just end the message with CTRL+D). I'll make a PR to improve the example. @terryjreedy May I shamefully take your idiom? By the way Hugo, the page is https://docs.python.org/3/library/smtplib.html#smtp-example. |
(cherry picked from commit 4bc27ab) Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
(cherry picked from commit 4bc27ab) Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
I think this one can now be closed @hugovk |
@picnixz (" May I shamefully take your idiom?") Yes! I am delighted to wake up and find my suggestion implemented and merged. |
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Documentation
The example code is meant to demonstrate sending a multi-line message. It does not do that; the lines get contracted into one.
This can be fixed by adding a newline character to the end of the line when it is added to the message string:
BTW, why not use PEP8 compliant names, f-strings, and context managers? Why make things complicated with a .strip() call? Why make it that blank lines in the message are like pressing send?
Linked PRs
smtplib
example #120668smtplib
example (GH-120668) #120681smtplib
example (GH-120668) #120682The text was updated successfully, but these errors were encountered: