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: email.message_from_string: initial line gets discarded
Type: Stage:
Components: Library (Lib) Versions: Python 2.5
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: barry Nosy List: barry, dwebster99, nnorwitz
Priority: normal Keywords:

Created on 2007-07-12 15:52 by dwebster99, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
email_tests.py dwebster99, 2007-07-12 15:52 message_from_string bug
Messages (3)
msg32484 - (view) Author: David Webster (dwebster99) Date: 2007-07-12 15:52
If the first line of the string passed to email.message_from_string starts with whitespace, the line gets discarded. I believe the problem is in the feed parser, but I don't have a test case to prove that. 

The attached file is a short program to illustrate the problem. When I run it I get the output shown below. The line count should be unchanged in both cases. 

leading whitespace :
    Body changed: lines in: 3  lines out: 2
left justified :
    Line count was preserved.

Platform:
  Python 2.5.1
  Windows 2000 SP4

msg32485 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2007-07-13 03:48
Barry, could you take a look?  Thanks.
msg32486 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2007-07-13 21:22
It is not legal for the first line of text to start with whitespace.  This makes it look like the message begins with a header continuation.

The first line isn't lost, it's tucked away on the resulting message's defect list.  Try printing 'msg.defects[0].line'.
History
Date User Action Args
2022-04-11 14:56:25adminsetgithub: 45187
2007-07-12 15:52:52dwebster99create