-
-
Notifications
You must be signed in to change notification settings - Fork 34.7k
gh-126845 email parsedate_to_datetime 3 digit year fix #150864
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
base: main
Are you sure you want to change the base?
Changes from all commits
7d56a01
e38deda
d71c0f8
cc4ec42
7db242d
d5a9948
55420b6
cbfabab
3747dad
e10af2d
213e475
0be6612
0907f21
2896ee9
d621858
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -146,15 +146,15 @@ def _parsedate_tz(data): | |
| return None | ||
| # Check for a yy specified in two-digit format, then convert it to the | ||
| # appropriate four-digit format, according to the POSIX standard. RFC 822 | ||
| # calls for a two-digit yy, but RFC 2822 (which obsoletes RFC 822) already | ||
| # mandated a 4-digit yy, and RFC 5322 (which obsoletes RFC 2822) continues | ||
| # this requirement. For more information, see the documentation for | ||
| # the time module. | ||
| if yy < 100: | ||
| # The year is between 1969 and 1999 (inclusive). | ||
| # calls for a two-digit yy, but RFC 2822 (which obsoletes RFC 822) | ||
| # mandated a 4-digit yyyy, and RFC 5322 (which obsoletes RFC 2822) | ||
| # continues this requirement. Two digit years between 69 and 99 inclusive, | ||
| # and three digit years, are to be interpreted as 1900s dates, while those | ||
| # 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: | ||
| yy += 1900 | ||
| # The year is between 2000 and 2068 (inclusive). | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The comment was correct. It should be updated after changing the threshold.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am fine with this. |
||
| else: | ||
| yy += 2000 | ||
| tzoffset = None | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| Fixed the :mod:`email` module parsing of three digit dates to | ||
| conform to :rfc:`5322`: three digit dates were previously | ||
| turned in to non-conformant four digit dates with a | ||
| leading ``0``. Now, per the RFC section 4.3, ``1990`` is added | ||
| to such dates to form compliant four digit years. | ||
|
|
||
| Contributed by Gustaf Gyllensporre. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.