Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
f-strings and date check
  • Loading branch information
Yoav11 committed Sep 21, 2026
commit 7b9af9236fb9c640d7c6159f6d600a37a8882e7c
2 changes: 1 addition & 1 deletion Lib/smtplib.py
Original file line number Diff line number Diff line change
Expand Up @@ -951,7 +951,7 @@ def send_message(self, msg, from_addr=None, to_addrs=None,
raise ValueError("message has more than one 'Resent-' header block")

# RFC 5322 section 3.6, 4th Paragraph
if msg.get('Date', None) is None:
if 'Date' not in msg:
# localtime: RFC 5322 section 3.3, 4th Paragraph
msg['Date'] = email.utils.formatdate(localtime=True)
if from_addr is None:
Expand Down
6 changes: 3 additions & 3 deletions Lib/test/test_smtplib.py
Original file line number Diff line number Diff line change
Expand Up @@ -1529,17 +1529,17 @@ def test_send_message_uses_smtputf8_if_addrs_non_ascii(self):
"UTC+02:00"
)
Comment thread
Yoav11 marked this conversation as resolved.

expected = textwrap.dedent("""\
expected = textwrap.dedent(f"""\
From: Páolo <főo@bar.com>
To: Dinsdale
Subject: Nudge nudge, wink, wink \u1F609
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
MIME-Version: 1.0
Date: {}
Date: {date}

oh là là, know what I mean, know what I mean?
""".format(date))
""")

self.assertEqual(self.serv.last_mailfrom, 'főo@bar.com')
self.assertEqual(self.serv.last_rcpttos, ['Dinsdale'])
Expand Down
Loading