mirror of
https://github.com/python/cpython.git
synced 2025-11-01 18:51:43 +00:00
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.
This commit is contained in:
parent
b808d590a2
commit
f9e3cf1f9f
4 changed files with 10 additions and 10 deletions
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue