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.

classification
Title: message.as_string hoses headers
Type: Stage:
Components: Library (Lib) Versions:
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: carlk, tim.peters
Priority: normal Keywords:

Created on 2004-04-20 21:52 by carlk, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
HoseHeader.py carlk, 2004-04-20 21:52
Messages (5)
msg20548 - (view) Author: Carl Karsten (carlk) Date: 2004-04-20 21:52
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@fiftyfive.com  Thu Apr 15 17:30:17 2004
To: <spm1@fiftyfive.com>
Subject: tst 17

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



msg20549 - (view) Author: Carl Karsten (carlk) Date: 2004-04-26 02:54
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
msg20550 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2004-04-26 03:11
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.
msg20551 - (view) Author: Carl Karsten (carlk) Date: 2004-04-26 03:22
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. )
msg20552 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2004-04-26 04:22
Logged In: YES 
user_id=31435

No problem.  Officially closed.
History
Date User Action Args
2022-04-11 14:56:03adminsetgithub: 40171
2004-04-20 21:52:28carlkcreate