summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomás Touceda <chiiph@leap.se>2014-01-27 15:33:44 -0300
committerTomás Touceda <chiiph@leap.se>2014-01-27 15:33:44 -0300
commita25a93d99d9c10b49279ec5b3568639db8ead67a (patch)
treef29e9b59f2ec81d9567eac0c1e0c477c9b66a474
parent99da1a88254d04908e8a223834369fe9ad130ebc (diff)
parent0068acc535a7e857576c047ece10134612dcffe9 (diff)
Merge remote-tracking branch 'refs/remotes/ivan/feature/improve-unicode-logs' into develop
-rw-r--r--mail/src/leap/mail/imap/messages.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/mail/src/leap/mail/imap/messages.py b/mail/src/leap/mail/imap/messages.py
index 5bb5f1c..34304ea 100644
--- a/mail/src/leap/mail/imap/messages.py
+++ b/mail/src/leap/mail/imap/messages.py
@@ -178,10 +178,11 @@ class MessagePart(object):
logger.debug("Got charset from header: %s" % (charset,))
if charset is None:
charset = self._get_charset(payload)
+ logger.debug("Got charset: %s" % (charset,))
try:
payload = payload.encode(charset)
except (UnicodeEncodeError, UnicodeDecodeError) as e:
- logger.error("Unicode error {0}".format(e))
+ logger.error("Unicode error, using 'replace'. {0!r}".format(e))
payload = payload.encode(charset, 'replace')
fd.write(payload)
@@ -530,7 +531,7 @@ class LeapMessage(fields, MailParser, MBoxParser):
try:
body = body.encode(charset)
except UnicodeError as e:
- logger.error("Unicode error {0}".format(e))
+ logger.error("Unicode error, using 'replace'. {0!r}".format(e))
body = body.encode(charset, 'replace')
# We are still returning funky characters from here.