diff options
author | Ivan Alejandro <ivanalejandro0@gmail.com> | 2014-01-27 14:49:16 -0300 |
---|---|---|
committer | Ivan Alejandro <ivanalejandro0@gmail.com> | 2014-01-27 14:54:18 -0300 |
commit | 17ea6fd404fd606c74776dc05ce769a7df43569a (patch) | |
tree | 60f2a30837176ea3fa567d95ab35deba84cff794 | |
parent | a49b005d2a584936f364192864b6758bb1dd1215 (diff) |
Use repr() on exceptions, inform if using 'replace'.
-rw-r--r-- | src/leap/mail/imap/messages.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/leap/mail/imap/messages.py b/src/leap/mail/imap/messages.py index 5bb5f1c..34304ea 100644 --- a/src/leap/mail/imap/messages.py +++ b/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. |