[Spambayes-checkins] spambayes/scripts sb_imapfilter.py,1.22,1.23
Tony Meyer
anadelonbrin at users.sourceforge.net
Wed Feb 4 20:16:03 EST 2004
Update of /cvsroot/spambayes/spambayes/scripts
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19557/scripts
Modified Files:
sb_imapfilter.py
Log Message:
Fix [ 890645 ] imapfilter: "ValueError: year out of range"
This guy was getting mail dated almost 2000 years ago (or 8000 years in the future, maybe, but it would be nice to think there won't be any spam then <wink>) and that choked mktime().
Fix that so that the fallback of the current time is used in that situation.
Index: sb_imapfilter.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/scripts/sb_imapfilter.py,v
retrieving revision 1.22
retrieving revision 1.23
diff -C2 -d -r1.22 -r1.23
*** sb_imapfilter.py 27 Jan 2004 08:36:51 -0000 1.22
--- sb_imapfilter.py 5 Feb 2004 01:16:01 -0000 1.23
***************
*** 341,344 ****
--- 341,355 ----
try:
return Time2Internaldate(time.mktime(parsed_date))
+ except ValueError:
+ # Invalid dates can cause mktime() to raise a
+ # ValueError, for example:
+ # >>> time.mktime(parsedate("Mon, 06 May 0102 10:51:16 -0100"))
+ # Traceback (most recent call last):
+ # File "<interactive input>", line 1, in ?
+ # ValueError: year out of range
+ # (Why this person is getting mail from almost two
+ # thousand years ago is another question <wink>).
+ # In any case, we just pass and use the current date.
+ pass
except OverflowError:
pass
More information about the Spambayes-checkins
mailing list