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. How would I go about recommending a change the module? Original code: def mktime_tz(data): """Turn a 10-tuple as returned by parsedate_tz() into a UTC timestamp.""" if data[9] is None: # No zone info, so localtime is better assumption than GMT return time.mktime(data[:8] + (-1,)) else: t = time.mktime(data[:8] + (0,)) return t - data[9] - time.timezone Patched code: def mktime_tz(data): """Turn a 10-tuple as returned by parsedate_tz() into a UTC timestamp.""" try: if data[9] is None: # No zone info, so localtime is better assumption than GMT return time.mktime(data[:8] + (-1,)) else: t = time.mktime(data[:8] + (0,)) return t - data[9] - time.timezone except TypeError: return time.mktime(data[:8] + (-1,)) ---- Auburn fans are like slinkys... not really good for anything but they still bring a smile to your face when you push them down a flight of stairs. To argue that honorable conduct is only required against an honorable enemy degrades the Americans who must carry out the orders. -- Charles Krulak, Former Commandant of the Marine Corps We are all slave to our own paradigm. -- Joshua Williams If the letters PhD appear after a person's name, that person will remain outdoors even after it's started raining. -- Jeff Kay -- http://mail.python.org/mailman/listinfo/python-list