[Spambayes-checkins] spambayes/Outlook2000 msgstore.py,1.44,1.45

Mark Hammond mhammond at users.sourceforge.net
Tue Jun 3 19:47:15 EDT 2003


Update of /cvsroot/spambayes/spambayes/Outlook2000
In directory sc8-pr-cvs1:/tmp/cvs-serv20925

Modified Files:
	msgstore.py 
Log Message:
Get even more brutal with the message when the email package still barfs.


Index: msgstore.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/Outlook2000/msgstore.py,v
retrieving revision 1.44
retrieving revision 1.45
diff -C2 -d -r1.44 -r1.45
*** msgstore.py	20 May 2003 00:30:45 -0000	1.44
--- msgstore.py	4 Jun 2003 01:47:13 -0000	1.45
***************
*** 666,670 ****
                  # structure, just the words it contains, so no harm and
                  # much good in trying to suppress this error.
!                 msg = email.message_from_string(text + "\n\n")
          except:
              print "FAILED to create email.message from: ", `text`
--- 666,687 ----
                  # structure, just the words it contains, so no harm and
                  # much good in trying to suppress this error.
!                 try:
!                     msg = email.message_from_string(text + "\n\n")
!                 except email.Errors.BoundaryError:
!                     # But even this doesn't get *everything*.  We can still see:
!                     #  "multipart message with no defined boundary"
!                     # so now it is time to turn into a butcher - hack out
!                     # the Content-Type header, so we see it as plain text.
!                     butcher_pos = text.lower().find("\ncontent-type: ")
!                     if butcher_pos < 0:
!                         # This error just just gunna get caught below anyway
!                         raise RuntimeError(
!                             "email package croaked with boundary error, but "
!                             "there appears to be no 'Content-Type' header")
!                     # Put it back together, skipping the original "\n" but
!                     # leaving the header leaving "\nSpamBayes-Content-Type: "
!                     butchered = text[:butcher_pos] + "\nSpamBayes-" + \
!                                 text[butcher_pos+1:] + "\n\n"
!                     msg = email.message_from_string(butchered)
          except:
              print "FAILED to create email.message from: ", `text`





More information about the Spambayes-checkins mailing list