TypeError Exception in email lib

Stephen Hansen apt.shansen at gmail.com
Mon Feb 15 14:31:11 EST 2010


On Mon, Feb 15, 2010 at 10:53 AM, BJ Swope <bigblueswope at gmail.com> wrote:

>  File "/usr/lib/python2.5/email/_parseaddr.py", line 142, in mktime_tz
>    if data[9] is None:
> TypeError: 'NoneType' object is unsubscriptable
>
> I'm parsing a bunch of spam and using the date field from the spams
> for a date-time stamp.
>
> I've fixed the lib on my box to place the call inside a try/except
> clause to catch the exception now, but it seems the module has a bug
> in it.
>

While there may or may not be a bug in the library, I don't think its where
you're fixing. Just because an exception occurs in a function doesn't mean
that function is broken: its documented as accepting a 10 item tuple, only.
Functions in the stdlib generally -should- throw exceptions on invalid
input.

Someone's passing None into it, which its not allowed to do. So -that's-
where the bug probably is, I think. (Although it may not be the immediate of
mktime_tz; it could be happening higher up on the stack)

Advice: Always post complete tracebacks to c.p.l/python-list :)

--S
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100215/2a3e3fef/attachment.html>


More information about the Python-list mailing list