[Spambayes] Re: imapfilter mangling headers!

David Abrahams dave at boost-consulting.com
Sun Apr 20 05:56:00 EDT 2003


"Meyer, Tony" <T.A.Meyer at massey.ac.nz> writes:

> [Time error]
>> > I've checked in a fix for this.
>> Not yet, I think. After an update:
>> 
>>     %python imapfilter.py -c -D ~/bayes.db
>>     Traceback (most recent call last):
>>       File "imapfilter.py", line 509, in ?
>>         run()
>>       File "imapfilter.py", line 499, in run
>>         imap_filter.Filter()
>>       File "imapfilter.py", line 391, in Filter
>>         self.unsure_folder)
>>       File "imapfilter.py", line 350, in Filter
>>         msg.Save()
>>       File "imapfilter.py", line 201, in Save
>>         msg_time = self.extractTime()
>>       File "imapfilter.py", line 178, in extractTime
>>         return imaplib.Time2Internaldate(\
>>     TypeError: argument must be 9-item sequence, not None
>
> A couple of things that are odd here.  The first is that extractTime
> should almost never be called now - the imap server should provide the
> time.  Could you execute the following and tell me what you get?
> (replacing the server-specific stuff, obviously)
>

    >>> import imaplib
    >>> imap = imaplib.IMAP4("mail.example.com")
    >>> imap.login("username", "password")
    ('OK', ['completed'])
    >>> imap.select()
    ('OK', ['5282'])
    >>> imap.fetch("1:1", "(INTERNALDATE)")
    ('OK', ['1 (INTERNALDATE "11-Mar-2003 18:37:56 +0000")'])
    >>> imap.logout()
    ('BYE', ['CommuniGate Pro IMAP closing connection'])


> The other odd thing is that the date header is definitely present
> (otherwise line 178 wouldn't execute) so it's either parsedate or mktime
> that's returning None.  Could you change line 178 to this and let me
> know what prints out?
>
>             Pd = parsedate(message_date)
              ^^ "pd"
>             print pd
>             md = mktime(pd)
                   ^^^^^^ "time.mktime"
>             print md
>             t2i = imaplib.Time2Internaldate(md)
>             print t2i
>             return t2i

After making the above corrections:

%python imapfilter.py -c -D ~/bayes.db
None
Traceback (most recent call last):
  File "imapfilter.py", line 529, in ?
    run()
  File "imapfilter.py", line 519, in run
    imap_filter.Filter()
  File "imapfilter.py", line 398, in Filter
    self.unsure_folder)
  File "imapfilter.py", line 357, in Filter
    msg.Save()
  File "imapfilter.py", line 208, in Save
    msg_time = self.extractTime()
  File "imapfilter.py", line 180, in extractTime
    md = time.mktime(pd)
TypeError: argument must be 9-item sequence, not None

> Thanks for the help in tracing these down.  Given the way that each
> imap server software seems to put it's own interpretation on the
> RFC, we need as many testers as possible.

No problem; I just wish I could get you an account so you could try
this stuff yourself.

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com




More information about the Spambayes mailing list