[New-bugs-announce] [issue44395] email.message as_string() not writing unixfrom

Konstantin Ryabitsev report at bugs.python.org
Fri Jun 11 10:15:26 EDT 2021


New submission from Konstantin Ryabitsev <konstantin at linuxfoundation.org>:

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 at bar Thu Jan  1 00:00:00 1970')
msg['Subject'] = 'Hello'
msg['From'] = 'Me <me at 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 at foo.bar>

Hello World

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

Hello World

----------
components: email
messages: 395635
nosy: barry, konstantin2, r.david.murray
priority: normal
severity: normal
status: open
title: email.message as_string() not writing unixfrom
versions: Python 3.9

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue44395>
_______________________________________


More information about the New-bugs-announce mailing list