This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author charlesc
Recipients charlesc
Date 2010-02-20.00:25:09
SpamBayes Score 2.6857182e-07
Marked as misclassified No
Message-id <1266625512.07.0.157339472909.issue7970@psf.upfronthosting.co.za>
In-reply-to
Content
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
    self._write(msg)
  File "/usr/local/lib/python2.6/email/generator.py", line 109, in _write
    self._dispatch(msg)
  File "/usr/local/lib/python2.6/email/generator.py", line 135, in _dispatch
    meth(msg)
  File "/usr/local/lib/python2.6/email/generator.py", line 266, in _handle_message
    g.flatten(msg.get_payload(0), unixfrom=False)
  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.
History
Date User Action Args
2010-02-20 00:25:12charlescsetrecipients: + charlesc
2010-02-20 00:25:12charlescsetmessageid: <1266625512.07.0.157339472909.issue7970@psf.upfronthosting.co.za>
2010-02-20 00:25:10charlesclinkissue7970 messages
2010-02-20 00:25:10charlesccreate