Skip to content

gh-73065: Add Date header if missing in smtplib send_message #136850

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

Yoav11
Copy link

@Yoav11 Yoav11 commented Jul 20, 2025

Description

this PR was created during EuroPython 2025 Sprint Weekend.

It builds on #5176 authored by @elafontaine


📚 Documentation preview 📚: https://cpython-previews--136850.org.readthedocs.build/

@python-cla-bot
Copy link

python-cla-bot bot commented Jul 20, 2025

All commit authors signed the Contributor License Agreement.

CLA signed

@Yoav11 Yoav11 changed the title gh-28879: Add Date header if missing in smtplib send_message bpo-28879: Add Date header if missing in smtplib send_message Jul 20, 2025
@StanFromIreland
Copy link
Member

Please change the title to use the GitHub issue number.

@Yoav11 Yoav11 changed the title bpo-28879: Add Date header if missing in smtplib send_message gh-73065: Add Date header if missing in smtplib send_message Jul 20, 2025
@Yoav11 Yoav11 marked this pull request as ready for review July 20, 2025 08:22
@Yoav11 Yoav11 requested a review from a team as a code owner July 20, 2025 08:22
@tomasr8 tomasr8 added the sprint label Jul 20, 2025
HOST, self.port, local_hostname='localhost',
timeout=support.LOOPBACK_TIMEOUT)
self.addCleanup(smtp.close)
self.assertEqual(smtp.send_message(msg), {})
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am moving these assertions further up so that I can extract the date from the message in order to build the expected string

@StanFromIreland
Copy link
Member

@Yoav11 A little suggestion, when you complete a suggestion, whether that be by implementing it or providing a reason why you are not going to, please mark the conversation as "Resolved," this keeps the PR more organized.

Copy link
Contributor

@ilovelinux ilovelinux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider mocking the date with a non-UTC time of which we know the timezone

Comment on lines +1490 to +1493
self.assertEqual(
email.utils.parsedate_to_datetime(date).tzname(),
"UTC+02:00"
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to make it work in any timezone

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you have a suggestion for a specific timezone ? my concern with using something more generic like australia/london etc. is that (although rare) there is some chance that the timezone name or DST conventions change over time which would break the test. As i'm only trying to assert that the user's local was respected in this test, i felt like using something like UTC+02 was less prone to flakiness in the future. But maybe my concern is unfounded, I don't have a ton of expertise with date times :p

@StanFromIreland
Copy link
Member

Please do not use the Update Branch button unless necessary (e.g. fixing conflicts, jogging the CI, or very old PRs) as it uses valuable resources. For more information see the devguide.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy