[ python-Bugs-938890 ] message.as_string hoses headers

SourceForge.net noreply at sourceforge.net
Sun Apr 25 23:22:25 EDT 2004


Bugs item #938890, was opened at 2004-04-20 16:52
Message generated for change (Comment added) made by carlk
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=938890&group_id=5470

Category: Python Library
Group: Python 2.3
>Status: Deleted
>Resolution: Rejected
Priority: 5
Submitted By: Carl Karsten (carlk)
Assigned to: Nobody/Anonymous (nobody)
Summary: message.as_string hoses headers

Initial Comment:
message.as_string()  doesn't output the first line.  It 
may be because the first line isn't a proper header per 
http://www.faqs.org/rfcs/rfc2822.html but I am not 
sure what is/isn't, nor do I think that .as_string() 
should be fixing my data.  

"print message" (no .as_string) outputs all the 
lines 'correctly' or at least the way I want.

Key lines from the attachment:

message = email.message_from_string(stdin)
print message.as_string()

$ ./HoseHeader.py <test2.txt >hosed2.txt

$ cat test2.txt
>From spm1 at fiftyfive.com  Thu Apr 15 17:30:17 2004
To: <spm1 at fiftyfive.com>
Subject: tst 17

$ cat hosed2.txt
To: <spm1 at fiftyfive.com>
Subject: tst 17





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

>Comment By: Carl Karsten (carlk)
Date: 2004-04-25 22:22

Message:
Logged In: YES 
user_id=317164

yeah, just caught that.  thanks for confirming.  (sorry about 
jumping the gun... I asked around and the concensus was: 
bug. )

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

Comment By: Tim Peters (tim_one)
Date: 2004-04-25 22:11

Message:
Logged In: YES 
user_id=31435

carlk, have you read the docs?  It's documented 
that .as_string() has on optional "unixfrom" argument, which 
defaults to False.  It's also documented that __str__ 
(which "print message" implicitly invokes) is the same as 
calling .as_string(unixfrom=True).  Change your print to

print message.as_string(unixfrom=True)

and see what happens.

AFAICT, you're simply seeing the documented behavior.

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

Comment By: Carl Karsten (carlk)
Date: 2004-04-25 21:54

Message:
Logged In: YES 
user_id=317164

I don't think this is a bug.  

"Note that in all cases, any envelope header present in the 
message is not included in the mapping interface. "

http://www.python.org/doc/2.3/lib/module-
email.Message.html

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

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



More information about the Python-bugs-list mailing list