[New-bugs-announce] [issue7970] email.Generator fails to flatten message parsed by email.Parser
report at bugs.python.org
Sat Feb 20 01:25:12 CET 2010
New submission from Charles Cazabon <charlesc-python at pyropus.ca>:
email.Generator fails to flatten a message parsed by email.Parser; it throws an exception with an odd (but apparently legal) message. First, the exception:
File "/usr/local/lib/python2.6/email/generator.py", line 84, in flatten
File "/usr/local/lib/python2.6/email/generator.py", line 109, in _write
File "/usr/local/lib/python2.6/email/generator.py", line 135, in _dispatch
File "/usr/local/lib/python2.6/email/generator.py", line 266, in _handle_message
File "/usr/local/lib/python2.6/email/message.py", line 189, in get_payload
raise TypeError('Expected list, got %s' % type(self._payload))
TypeError: Expected list, got <type 'str'>
The oddity of the message its handling is that it's a single-part MIME message, where the content-type is declared as message/rfc822. Most MUAs, when forwarding message, create a multipart MIME message with a single attachment part, and have the attachment be message/rfc822. But Groupwise, when configured to forward messages to another address (without specifying an additional text to insert with the forwarded message) creates these slightly odd messages.
I've not seen them before, but a couple of getmail users have run into this issue. I've confirmed the problem is the same in Python 2.3, 2.4, 2.5, and 2.6, and I presume it's the same in 2.7 but haven't tested yet.
I'll attach a minimal test script and a datafile which is a minimal message showing the problem.
components: Library (Lib)
title: email.Generator fails to flatten message parsed by email.Parser
versions: Python 2.5, Python 2.6
Added file: http://bugs.python.org/file16262/testcase.py
Python tracker <report at bugs.python.org>
More information about the New-bugs-announce