Skip to content

gh-126845 email parsedate_to_datetime 3 digit year fix#150864

Open
bitdancer wants to merge 15 commits into
python:mainfrom
bitdancer:datetime_3_digit_year_fix-126845-123438_fixup
Open

gh-126845 email parsedate_to_datetime 3 digit year fix#150864
bitdancer wants to merge 15 commits into
python:mainfrom
bitdancer:datetime_3_digit_year_fix-126845-123438_fixup

Conversation

@bitdancer
Copy link
Copy Markdown
Member

@bitdancer bitdancer commented Jun 3, 2026

@gostak-dd: This is a reconstruction of pr #134438 after I messed it up with web merge, built by cherry picking all the commits and resolving the conflicts with current main.

@@ -0,0 +1,7 @@
Fixed the :mod:`email` module parsing of three digit dates to
conform to :rfc:`5322`: three digit dates were previously
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This file has CRLF line endings, resulting in the CI failure.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Is that because I used the web editor? Is github really that broken?

Fixed.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is that because I used the web editor? Is github really that broken?

Yep :'-(

Copy link
Copy Markdown
Member

@serhiy-storchaka serhiy-storchaka left a comment

Choose a reason for hiding this comment

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

I understand the rationale. This is to handle output of non-Y2000-compatible software.

Comment thread Lib/email/_parseaddr.py
# between 0 and 68 are to be treated as 2000s dates.
# (https://datatracker.ietf.org/doc/html/rfc5322#section-4.3)
if yy < 1000:
if yy > 68:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The threshold is 49 according to RFC 5322.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

See my comment on the issue for discussion on this.

Comment thread Lib/email/_parseaddr.py
if yy < 1000:
if yy > 68:
yy += 1900
# The year is between 2000 and 2068 (inclusive).
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The comment was correct. It should be updated after changing the threshold.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I feel like the two comments on the if/else are redundant after the change to the block comment above it, but if you prefer to keep those two comments I'll add them back.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I am fine with this.

Comment thread Lib/test/test_email/test_utils.py
Comment thread Lib/email/_parseaddr.py
if yy < 1000:
if yy > 68:
yy += 1900
# The year is between 2000 and 2068 (inclusive).
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I am fine with this.

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.

4 participants