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 hsp
Recipients hsp
Date 2007-12-05.15:51:15
SpamBayes Score 0.043459002
Marked as misclassified No
Message-id <1196869876.98.0.0449623543334.issue1556@psf.upfronthosting.co.za>
In-reply-to
Content
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'>
Files
File name Uploaded
MimebaseError.py hsp, 2007-12-05.15:51:15
History
Date User Action Args
2007-12-05 15:51:17hspsetspambayes_score: 0.043459 -> 0.043459002
recipients: + hsp
2007-12-05 15:51:17hspsetspambayes_score: 0.043459 -> 0.043459
messageid: <1196869876.98.0.0449623543334.issue1556@psf.upfronthosting.co.za>
2007-12-05 15:51:16hsplinkissue1556 messages
2007-12-05 15:51:15hspcreate