[New-bugs-announce] [issue1556] Failure when calling __str__ for MIMEBase(message, rfc822) objects
Hendrik Spiegel
report at bugs.python.org
Wed Dec 5 16:51:17 CET 2007
New submission from Hendrik Spiegel:
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'>
----------
components: Library (Lib)
files: MimebaseError.py
messages: 58216
nosy: hsp
severity: normal
status: open
title: Failure when calling __str__ for MIMEBase(message, rfc822) objects
type: crash
versions: Python 2.4, Python 2.5
Added file: http://bugs.python.org/file8879/MimebaseError.py
__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue1556>
__________________________________
-------------- next part --------------
A non-text attachment was scrubbed...
Name: MimebaseError.py
Type: text/x-python
Size: 468 bytes
Desc: not available
Url : http://mail.python.org/pipermail/new-bugs-announce/attachments/20071205/6b66baf8/attachment.py
More information about the New-bugs-announce
mailing list