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.
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 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: