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.

Author konstantin2
Recipients barry, konstantin2, r.david.murray
Date 2021-06-11.14:15:25
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1623420926.37.0.619875341642.issue44395@roundup.psfhosted.org>
In-reply-to
Content
When using as_string(unixfrom=True), the "From " line is not always printed. The behaviour is correct for as_bytes().

Test case:

----
import email.message

msg = email.message.EmailMessage()
msg.set_payload('Hello World\n')
msg.set_unixfrom('From foo@bar Thu Jan  1 00:00:00 1970')
msg['Subject'] = 'Hello'
msg['From'] = 'Me <me@foo.bar>'
print('as_string:')
print(msg.as_string(unixfrom=True))
print('as_bytes:')
print(msg.as_bytes(unixfrom=True).decode())
----

Results (3.5 and 3.9):

as_string:
Subject: Hello
From: Me <me@foo.bar>

Hello World

as_bytes:
From foo@bar Thu Jan  1 00:00:00 1970
Subject: Hello
From: Me <me@foo.bar>

Hello World
History
Date User Action Args
2021-06-11 14:15:26konstantin2setrecipients: + konstantin2, barry, r.david.murray
2021-06-11 14:15:26konstantin2setmessageid: <1623420926.37.0.619875341642.issue44395@roundup.psfhosted.org>
2021-06-11 14:15:26konstantin2linkissue44395 messages
2021-06-11 14:15:25konstantin2create