[Spambayes-checkins] spambayes/spambayes message.py,1.8,1.9

Tim Stone timstone4 at users.sourceforge.net
Sun Apr 13 06:54:05 EDT 2003


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

Modified Files:
	message.py 
Log Message:
Raised an error on RememberClassification if the classification to be
remembered is not recognizable.

Index: message.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/spambayes/message.py,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** message.py	13 Apr 2003 02:02:54 -0000	1.8
--- message.py	13 Apr 2003 12:54:02 -0000	1.9
***************
*** 142,151 ****
      def setPayload(self, payload):
          prs = email.Parser.Parser()
          # this is kindof a hack, due to the fact that the parser creates a
          # new message object, and we already have the message object
!         prs._parseheaders(self, StringIO(payload))
          # we may want to do some header parsing error handling here
          # to try to extract important headers regardless of malformations
!         prs._parsebody(self, StringIO(payload))
          
      def setId(self, id):
--- 142,152 ----
      def setPayload(self, payload):
          prs = email.Parser.Parser()
+         fp = StringIO(payload)
          # this is kindof a hack, due to the fact that the parser creates a
          # new message object, and we already have the message object
!         prs._parseheaders(self, fp)
          # we may want to do some header parsing error handling here
          # to try to extract important headers regardless of malformations
!         prs._parsebody(self, fp)
          
      def setId(self, id):
***************
*** 153,159 ****
              raise ValueError, "MsgId has already been set, cannot be changed"
  
-         # XXX This isn't really needed since type(None) is not
-         # XXX in types.StringTypes - do we still want it for the
-         # XXX more informative error message?
          if id is None:
              raise ValueError, "MsgId must not be None"
--- 154,157 ----
***************
*** 170,175 ****
  
      def asTokens(self):
-         # use as_string() here because multipart/digest will return
-         # a list of message objects if get_payload() is used
          return tokenize(self.as_string())
          
--- 168,171 ----
***************
*** 199,204 ****
          elif cls == options.header_ham_string:
              self.c = 'h'
!         else:
              self.c = 'u'
  
          self.modified()
--- 195,203 ----
          elif cls == options.header_ham_string:
              self.c = 'h'
!         elif cls == options.header_unsure_string:
              self.c = 'u'
+         else:
+             raise ValueError, \
+                   "Classification must match header strings in options"
  
          self.modified()
***************
*** 213,217 ****
           
      def __repr__(self):
!         return "core.Message%r" % repr(self.__getstate__())
  
      def __getstate__(self):
--- 212,216 ----
           
      def __repr__(self):
!         return "spambayes.message.Message%r" % repr(self.__getstate__())
  
      def __getstate__(self):





More information about the Spambayes-checkins mailing list