David Abrahams
<[EMAIL PROTECTED]> writes:

> FYI, with the CVS HEAD as of 18 January:
>
>   Loading state from /usr/home/dave/hammie.new.db database
>   /usr/home/dave/hammie.new.db is a new database
>   Loading database /usr/home/dave/hammie.new.db... Done.
>   Account: www.stlport.com:993
>   Training
>      Training ham folder HamBox
>   Traceback (most recent call last):
>     File "/usr/home/dave/src/spambayes/scripts/sb_imapfilter.py", line 1283, 
> in ?
>       run()
>     File "/usr/home/dave/src/spambayes/scripts/sb_imapfilter.py", line 1261, 
> in run
>       imap_filter.Train()
>     File "/usr/home/dave/src/spambayes/scripts/sb_imapfilter.py", line 1004, 
> in Train
>       num_trained = folder.Train(self.classifier, is_spam)
>     File "/usr/home/dave/src/spambayes/scripts/sb_imapfilter.py", line 888, 
> in Train
>       for msg in self:
>     File "/usr/home/dave/src/spambayes/scripts/sb_imapfilter.py", line 799, 
> in __iter__
>       yield self[key]
>     File "/usr/home/dave/src/spambayes/scripts/sb_imapfilter.py", line 831, 
> in __getitem__
>       data = self.imap_server.extract_fetch_data(response_data)
>     File "/usr/home/dave/src/spambayes/scripts/sb_imapfilter.py", line 455, 
> in extract_fetch_data
>       msg_data = self._extract_fetch_data(msg)
>     File "/usr/home/dave/src/spambayes/scripts/sb_imapfilter.py", line 428, 
> in _extract_fetch_data
>       raise BadIMAPResponseError("FETCH response", response)
>   __main__.BadIMAPResponseError: The command 'FETCH response' failed to give 
> an OK response.
>   (' UID 1967)',)
>
> Rolling back to the last released version of spambayes makes this
> problem go away.

Since there's been no response, I decided to try to debug this a
little bit myself.  I know little about the workings of IMAP, but the
problem appears to be that sb_imapfilter isn't accounting for
responses like this one:

[('6 (BODY[] {3130}', 'Return-Path: <MAILER-DAEMON....'), ' UID 6)']

In particular, that last fragment is throwing it off.  I don't know
whether the real bug is in whatever gets passed to sb_imapfilter to be
used as its "server" attribute, or whether its here.

The following patch (which, given my scant knowledge, is almost
certainly wrong) makes the problem disappear for me.

I hope someone can at least follow up on this enough to tell me
whether I need to learn more about IMAP ;-)

Index: sb_imapfilter.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/scripts/sb_imapfilter.py,v
retrieving revision 1.66
diff -b -d -u -b -u -r1.66 sb_imapfilter.py
--- sb_imapfilter.py	7 Apr 2006 02:36:40 -0000	1.66
+++ sb_imapfilter.py	7 Aug 2006 17:10:10 -0000
@@ -385,6 +385,7 @@
     BODY_PEEK_RE = re.compile(r"(BODY\[\]) (\{[\d]+\})")
     RFC822_HEADER_RE = re.compile(r"(RFC822.HEADER) (\{[\d]+\})")
     UID_RE = re.compile(r"(UID) ([\d]+)")
+    UID_RE2 = re.compile(r" *(UID) ([\d]+)\)")
     FETCH_RESPONSE_RE = re.compile(r"([0-9]+) \(([" + \
                                    re.escape(FLAG_CHARS) + r"\"\{\}\(\)\\ ]*)\)?")
     LITERAL_RE = re.compile(r"^\{[\d]+\}$")
@@ -406,6 +407,9 @@
 
         data = {}
         expected_literal = None
+        if self.UID_RE2.match(response[-1]):
+            response = response[:-1]
+            
         for part in response:
             # We ignore parentheses by themselves, for convenience.
             if part == ')':
Thanks,

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com
_______________________________________________
spambayes-dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/spambayes-dev

Reply via email to