TypeError Exception in email lib
MRAB
python at mrabarnett.plus.com
Mon Feb 15 15:42:42 EST 2010
BJ Swope wrote:
[snip]
>
> Speak of the devil and demons appear...
>
> /logs/python/imap_fetcher/spam_serv1.bigbluenetworks.com.py
>
> Parsing of emails for spam at serv1.bigbluenetworks.com failed.
>
> Traceback (most recent call last):
> File "/logs/python/imap_fetcher/spam_serv1.bigbluenetworks.com.py",
> line 81, in <module>
> clean_stale_mail()
> File "/logs/python/imap_fetcher/spam_serv1.bigbluenetworks.com.py",
> line 24, in clean_stale_mail
> utc_msg_date = email.utils.mktime_tz(msg_date2)
> File "/usr/lib/python2.5/email/_parseaddr.py", line 142, in mktime_tz
> if data[9] is None:
> TypeError: 'NoneType' object is unsubscriptable
>
>
>
> def clean_stale_mail():
> msg_date1= the_email.get('Date')
What is the value of 'msg_date1' at this point?
> msg_date2 = email.utils.parsedate_tz(msg_date1)
What is the value of 'msg_date2' at this point?
The docs say that parsedate_tz() can return a 10-tuple or None.
Presumably, if it can't parse the date then it returns None.
> try:
> utc_msg_date = email.utils.mktime_tz(msg_date2)
> except OverflowError:
> M.store(msg_id, '+FLAGS.SILENT', '\\Deleted')
> return
> utc_stale_date = time.time() - (86000*stale_days)
> if utc_msg_date <= utc_stale_date:
> M.store(msg_id, '+FLAGS.SILENT', '\\Deleted')
>
[snip]
More information about the Python-list
mailing list