Permalink
Browse files

Fix a regression introduced in b58ac76 when using python 2.7

b58ac76 introduced a workaround for functionality missing from the
email API. This workaround caused problems users of python 2.7, so it
is now only used when run with python 3.1.

Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
  • Loading branch information...
1 parent 45d69d2 commit 8abd64bfdcd83a486b2a3977c08fe071523b2551 Justus Winter committed May 8, 2012
Showing with 4 additions and 1 deletion.
  1. +4 −1 afew/utils.py
View
@@ -88,7 +88,10 @@ def extract_mail_body(message):
if hasattr(email, 'message_from_binary_file'):
mail = email.message_from_binary_file(open(message.get_filename(), 'br'))
else:
- fp = codecs.open(message.get_filename(), 'r', 'utf-8', errors='replace')
+ if (3, 1) <= sys.version_info < (3, 2):
+ fp = codecs.open(message.get_filename(), 'r', 'utf-8', errors='replace')
+ else:
+ fp = open(message.get_filename())
mail = email.message_from_file(fp)
content = []

0 comments on commit 8abd64b

Please sign in to comment.