From: Thomas Jarosch Date: Fri, 29 Jun 2012 16:05:31 +0000 (+0200) Subject: Fix crash during exception handling X-Git-Url: http://developer.intra2net.com/git/?p=imap-fix-internaldate;a=commitdiff_plain;h=67d0bfd494161ce3a3bef99717c8574c389f6fd9 Fix crash during exception handling --- diff --git a/src/mail_iterator.py b/src/mail_iterator.py index a30af21..3ebe01b 100644 --- a/src/mail_iterator.py +++ b/src/mail_iterator.py @@ -87,7 +87,7 @@ class MailIterator: try: result, data = self.mail_con.uid('fetch', mid, '(INTERNALDATE)') except: - raise UserWarning("Could not fetch the internal date of message" + mid + ".") + raise UserWarning("Could not fetch the internal date of message" + mid.decode('iso-8859-1') + ".") internal_date = imaplib.Internaldate2tuple(data[0]) return internal_date @@ -96,7 +96,7 @@ class MailIterator: try: result, data = self.mail_con.uid('fetch', mid, '(BODY.PEEK[HEADER.FIELDS (RECEIVED)])') except: - raise UserWarning("Could not fetch the received header of message" + mid + ".") + raise UserWarning("Could not fetch the received header of message" + mid.decode('iso-8859-1') + ".") return data[0][1].decode('iso-8859-1') def update_message(self, mid, mailbox, internal_date): @@ -114,11 +114,11 @@ class MailIterator: internal_date_str, data[0][1]) logging.debug("Adding corrected copy of the message reponse: %s %s", result, data) except: - raise UserWarning("Could not replace the e-mail" + mid + ".") + raise UserWarning("Could not replace the e-mail" + mid.decode('iso-8859-1') + ".") try: result, data = self.mail_con.uid('STORE', mid, '+FLAGS', r'(\Deleted)') logging.debug("Removing old copy of the message reponse: %s %s", result, data) except: - raise UserWarning("Could not delete the e-mail" + mid + ".") + raise UserWarning("Could not delete the e-mail" + mid.decode('iso-8859-1') + ".") self.mail_con.expunge() return