When creating a MIMEBase object with message/rfc822 mimetype invoking
the objects __str__ method results in an exception.
Even if this behaviour should be intended the error message "TypeError:
Expected list, got <type 'str'>" is not helpful.
To reproduce the problem run the attached script after creating the file
'test.eml' in the script's directory.
mimetype = mimetypes.guess_type(filename)[0]
maintype, subtype = mimetype.split('/')
attachment = MIMEBase(maintype, subtype)
attachment.set_payload(file(filename).read( ))
print attachment
#python MimebaseError.py
[1]
message/rfc822
Traceback (most recent call last):
File "MimebaseError.py", line 19, in <module>
main()
File "MimebaseError.py", line 16, in main
print attachment
File "email/message.py", line 116, in __str__
File "email/message.py", line 131, in as_string
File "email/generator.py", line 84, in flatten
File "email/generator.py", line 109, in _write
File "email/generator.py", line 135, in _dispatch
File "email/generator.py", line 266, in _handle_message
File "email/message.py", line 185, in get_payload
TypeError: Expected list, got <type 'str'>
|