summaryrefslogtreecommitdiff
path: root/Doc/includes/email-unpack.py
diff options
context:
space:
mode:
authorR David Murray <rdmurray@bitdance.com>2016-09-07 21:15:59 -0400
committerR David Murray <rdmurray@bitdance.com>2016-09-07 21:15:59 -0400
commit29d1bc0842e5b086813aa7de4ab18f1c192d2291 (patch)
treeb812609f72f860adb5203ba9cbb1d0c4299e39af /Doc/includes/email-unpack.py
parent23e863378124229928e12b72c22df33f1428c61e (diff)
downloadcpython-git-29d1bc0842e5b086813aa7de4ab18f1c192d2291.tar.gz
#24277: The new email API is no longer provisional.
This is a wholesale reorganization and editing of the email documentation to make the new API the standard one, and the old API the 'legacy' one. The default is still the compat32 policy, for backward compatibility. We will change that eventually.
Diffstat (limited to 'Doc/includes/email-unpack.py')
-rw-r--r--Doc/includes/email-unpack.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/Doc/includes/email-unpack.py b/Doc/includes/email-unpack.py
index 574a0b6d72..e0a7f01f58 100644
--- a/Doc/includes/email-unpack.py
+++ b/Doc/includes/email-unpack.py
@@ -3,11 +3,11 @@
"""Unpack a MIME message into a directory of files."""
import os
-import sys
import email
-import errno
import mimetypes
+from email.policy import default
+
from argparse import ArgumentParser
@@ -22,8 +22,8 @@ Unpack a MIME message into a directory of files.
parser.add_argument('msgfile')
args = parser.parse_args()
- with open(args.msgfile) as fp:
- msg = email.message_from_file(fp)
+ with open(args.msgfile, 'rb') as fp:
+ msg = email.message_from_binary_file(fp, policy=default)
try:
os.mkdir(args.directory)