summaryrefslogtreecommitdiffstats
path: root/Doc/includes/email-read-alternative-new-api.py
diff options
context:
space:
mode:
Diffstat (limited to 'Doc/includes/email-read-alternative-new-api.py')
-rw-r--r--Doc/includes/email-read-alternative-new-api.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/Doc/includes/email-read-alternative-new-api.py b/Doc/includes/email-read-alternative-new-api.py
index 8ab4e9f..3f5ab24 100644
--- a/Doc/includes/email-read-alternative-new-api.py
+++ b/Doc/includes/email-read-alternative-new-api.py
@@ -12,7 +12,8 @@ from email.parser import BytesParser
from imaginary import magic_html_parser
# In a real program you'd get the filename from the arguments.
-msg = BytesParser(policy=policy.default).parse(open('outgoing.msg', 'rb'))
+with open('outgoing.msg', 'rb') as fp:
+ msg = BytesParser(policy=policy.default).parse(fp)
# Now the header items can be accessed as a dictionary, and any non-ASCII will
# be converted to unicode: