Problems with multipart messages w/email class
Joseph Wilhelm
jwilhelm at outsourcefinancial.com
Fri Mar 1 17:18:14 EST 2002
On Fri, 2002-03-01 at 11:12, Joseph Wilhelm wrote:
<snip>
> Traceback (most recent call last):
> File "<stdin>", line 1, in ?
> File "/opt/python/lib/python2.2/email/Message.py", line 59, in
> as_string
> g(self, unixfrom=unixfrom)
> File "/opt/python/lib/python2.2/email/Generator.py", line 83, in
> __call__
> self._write(msg)
> File "/opt/python/lib/python2.2/email/Generator.py", line 104, in
> _write
> self._dispatch(msg)
> File "/opt/python/lib/python2.2/email/Generator.py", line 134, in
> _dispatch
> meth(msg)
> File "/opt/python/lib/python2.2/email/Generator.py", line 240, in
> _handle_multipart
> for part in msg.get_payload():
> File "/opt/python/lib/python2.2/email/Message.py", line 151, in
> __getitem__
> return self.get(name)
> File "/opt/python/lib/python2.2/email/Message.py", line 214, in get
> name = name.lower()
> AttributeError: 'int' object has no attribute 'lower'
<snip>
Well, I have gotten a small fix for this traceback put into my copy of
Generator.py. I don't know if it should be necessarry, but this is what
I got to make it work (At line 240):
I replaced
for part in msg.get_payload():
With
pload = msg.get_payload()
if type( pload ) is not ListType:
pload = [ pload ]
for part in pload:
Just something very small and simple, but it was necessarry to make this
email work properly. Any comments on this? Is this a known bug? Is there
something I may have done wrong that would cause the previous error?
--Joseph Wilhelm
More information about the Python-list
mailing list