diff options
author | Berker Peksag <berker.peksag@gmail.com> | 2015-02-25 16:14:09 (GMT) |
---|---|---|
committer | Berker Peksag <berker.peksag@gmail.com> | 2015-02-25 16:14:09 (GMT) |
commit | f9e3cf1f9f6eaefba19593783e1cdf7681d1fa65 (patch) | |
tree | cbaa625efe90eefd38a96cc7577e2d28b135cae0 /Doc/includes/email-mime.py | |
parent | b808d590a24066bc03d21b55ed5e890a012477a8 (diff) | |
download | cpython-f9e3cf1f9f6eaefba19593783e1cdf7681d1fa65.zip cpython-f9e3cf1f9f6eaefba19593783e1cdf7681d1fa65.tar.gz cpython-f9e3cf1f9f6eaefba19593783e1cdf7681d1fa65.tar.bz2 |
Issue #23511: Port email-simple.py to Python 3.
Also, update email examples to use the context manager version of open().
Patch by Baptiste Mispelon.
Diffstat (limited to 'Doc/includes/email-mime.py')
-rw-r--r-- | Doc/includes/email-mime.py | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/Doc/includes/email-mime.py b/Doc/includes/email-mime.py index a90edc1..61d0830 100644 --- a/Doc/includes/email-mime.py +++ b/Doc/includes/email-mime.py @@ -20,9 +20,8 @@ msg.preamble = 'Our family reunion' for file in pngfiles: # Open the files in binary mode. Let the MIMEImage class automatically # guess the specific image type. - fp = open(file, 'rb') - img = MIMEImage(fp.read()) - fp.close() + with open(file, 'rb') as fp: + img = MIMEImage(fp.read()) msg.attach(img) # Send the email via our own SMTP server. |