classification
Title: email.message as_string() not writing unixfrom
Type: Stage: resolved
Components: email Versions: Python 3.11, Python 3.10, Python 3.9
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: FFY00, barry, corona10, konstantin2, miss-islington, r.david.murray
Priority: normal Keywords: patch

Created on 2021-06-11 14:15 by konstantin2, last changed 2021-06-21 14:27 by corona10. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 26685 merged corona10, 2021-06-12 01:08
PR 26828 merged miss-islington, 2021-06-21 13:59
PR 26829 merged miss-islington, 2021-06-21 13:59
Messages (4)
msg395635 - (view) Author: Konstantin Ryabitsev (konstantin2) Date: 2021-06-11 14:15
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
msg396247 - (view) Author: Dong-hee Na (corona10) * (Python committer) Date: 2021-06-21 13:59
New changeset 30f7a77f359a0fc6e37988b0f317a77a15d66b7b by Dong-hee Na in branch 'main':
bpo-44395: Fix MIMEPart.as_string to pass unixfrom properly (GH-26685)
https://github.com/python/cpython/commit/30f7a77f359a0fc6e37988b0f317a77a15d66b7b
msg396248 - (view) Author: miss-islington (miss-islington) Date: 2021-06-21 14:27
New changeset 20a1495b8a93596b322ea19bb09008db036eb7e6 by Miss Islington (bot) in branch '3.10':
bpo-44395: Fix MIMEPart.as_string to pass unixfrom properly (GH-26685)
https://github.com/python/cpython/commit/20a1495b8a93596b322ea19bb09008db036eb7e6
msg396249 - (view) Author: miss-islington (miss-islington) Date: 2021-06-21 14:27
New changeset 67b3a9995368f89b7ce4a995920b2a83a81c599b by Miss Islington (bot) in branch '3.9':
bpo-44395: Fix MIMEPart.as_string to pass unixfrom properly (GH-26685)
https://github.com/python/cpython/commit/67b3a9995368f89b7ce4a995920b2a83a81c599b
History
Date User Action Args
2021-06-21 14:27:56corona10setstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2021-06-21 14:27:46miss-islingtonsetmessages: + msg396249
2021-06-21 14:27:35miss-islingtonsetmessages: + msg396248
2021-06-21 13:59:18miss-islingtonsetpull_requests: + pull_request25410
2021-06-21 13:59:12miss-islingtonsetnosy: + miss-islington
pull_requests: + pull_request25409
2021-06-21 13:59:10corona10setmessages: + msg396247
2021-06-12 01:09:27corona10setversions: + Python 3.10, Python 3.11
2021-06-12 01:08:58corona10setkeywords: + patch
stage: patch review
pull_requests: + pull_request25273
2021-06-12 00:51:17corona10setnosy: + corona10
2021-06-11 19:06:36FFY00setnosy: + FFY00
2021-06-11 14:15:26konstantin2create