Fix crash during exception handling
authorThomas Jarosch <thomas.jarosch@intra2net.com>
Fri, 29 Jun 2012 16:05:31 +0000 (18:05 +0200)
committerThomas Jarosch <thomas.jarosch@intra2net.com>
Fri, 29 Jun 2012 16:05:31 +0000 (18:05 +0200)
src/mail_iterator.py

index a30af21..3ebe01b 100644 (file)
@@ -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