New submission from Charles Cazabon <charlesc-pyt...@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
    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.

----------
components: Library (Lib)
files: testcase.py
messages: 99606
nosy: charlesc
severity: normal
status: open
title: email.Generator fails to flatten message parsed by email.Parser
type: behavior
versions: Python 2.5, Python 2.6
Added file: http://bugs.python.org/file16262/testcase.py

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue7970>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to