[Python-bugs-list] [ python-Bugs-574605 ] Message.as_string() fails for multipart

noreply@sourceforge.net noreply@sourceforge.net
Fri, 28 Jun 2002 23:07:24 -0700


Bugs item #574605, was opened at 2002-06-27 10:35
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=574605&group_id=5470

Category: Python Library
Group: Python 2.2.1
>Status: Closed
>Resolution: Out of Date
Priority: 5
Submitted By: Moshe Yudkowsky (myudkowsky)
>Assigned to: Barry A. Warsaw (bwarsaw)
Summary: Message.as_string() fails for multipart

Initial Comment:
email.Message.Message has a method as_string(), which
according to documentation should print out the entire
message. However, if I build up a message using
add_payload() several times, as_string() fails.

as_string() fails because the message body becomes a
list instead of a string if it's a multipart message.

I enclose a file that "fixes" this problem; it's for
email/Generator.py, class Generator, and replaces def 
_handle_text(). Intead of testing for just type String,
it tests for type String and type List; if it's a list,
it tests to see that each list item is a string, and
then concatenates the strings into a string for printout.

Someone better versed in Message had better review this!



----------------------------------------------------------------------

>Comment By: Barry A. Warsaw (bwarsaw)
Date: 2002-06-29 02:07

Message:
Logged In: YES 
user_id=12800

I believe this is the known problem that led to the
deprecation of add_payload().  You should use the attach()
method instead.  Note that some fixes didn't make it into
Python 2.2.1 (I'm too tired to remember) but Python 2.3's
cvs is up-to-date and should/will be backported to Python 2.2.2.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=574605&group_id=5470