Skip to content

gh-126845: Some edge cases in email.utils.parsedate_to_datetime seem to differ from RFC2822 spec#134438

Closed
gostak-dd wants to merge 16 commits into
python:mainfrom
gostak-dd:bugfix/parsedate_to_datetime
Closed

gh-126845: Some edge cases in email.utils.parsedate_to_datetime seem to differ from RFC2822 spec#134438
gostak-dd wants to merge 16 commits into
python:mainfrom
gostak-dd:bugfix/parsedate_to_datetime

Conversation

@gostak-dd
Copy link
Copy Markdown
Contributor

@gostak-dd gostak-dd commented May 21, 2025

Continuation of PR #134350 which was mistakenly closed due to deleted local fork.

Regarding no.1 from #126845

Also added tests for different digit years and updated a test in test_email.py to correctly assert 1 digit years (03 is evaluated to 3)

Copy link
Copy Markdown
Member

@encukou encukou left a comment

Choose a reason for hiding this comment

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

This parses 0001 correctly, but breaks parsing of real two-digit years.

Comment thread Lib/email/_parseaddr.py Outdated
Comment thread Lib/test/test_email/test_email.py Outdated
Comment thread Lib/test/test_email/test_parsedate_to_datetime.py Outdated
Comment thread Lib/test/test_email/test_parsedate_to_datetime.py Outdated
Comment thread Lib/test/test_email/test_parsedate_to_datetime.py Outdated
Comment thread Lib/test/test_email/test_parsedate_to_datetime.py Outdated
@bedevere-app
Copy link
Copy Markdown

bedevere-app Bot commented Jun 10, 2025

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@gostak-dd
Copy link
Copy Markdown
Contributor Author

I have made the requested changes; please review again

@bedevere-app
Copy link
Copy Markdown

bedevere-app Bot commented Jul 17, 2025

Thanks for making the requested changes!

@bitdancer: please review the changes made to this pull request.

@bedevere-app bedevere-app Bot requested a review from bitdancer July 17, 2025 19:58
@github-actions
Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Apr 25, 2026
@gostak-dd
Copy link
Copy Markdown
Contributor Author

Hi @bitdancer could you please review?

Copy link
Copy Markdown
Member

@bitdancer bitdancer left a comment

Choose a reason for hiding this comment

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

Sorry about the long wait for a re-review. I'll do my best to review new changes more promptly.

Comment thread Lib/email/_parseaddr.py Outdated
Comment thread Lib/email/_parseaddr.py Outdated
Comment thread Lib/email/_parseaddr.py
Comment thread Lib/test/test_email/test_utils.py Outdated
Comment thread Lib/test/test_email/test_utils.py Outdated
@bedevere-app
Copy link
Copy Markdown

bedevere-app Bot commented Jun 2, 2026

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@gostak-dd gostak-dd force-pushed the bugfix/parsedate_to_datetime branch from a975f26 to 9a40eed Compare June 2, 2026 16:57
@gostak-dd
Copy link
Copy Markdown
Contributor Author

I have made the requested changes; please review again

@bitdancer

@bedevere-app
Copy link
Copy Markdown

bedevere-app Bot commented Jun 2, 2026

Thanks for making the requested changes!

@bitdancer: please review the changes made to this pull request.

@bedevere-app bedevere-app Bot requested a review from bitdancer June 2, 2026 16:57
@hugovk hugovk removed request for a team, ambv, brettcannon, gpshead, vsajip and warsaw June 2, 2026 17:21
@bitdancer
Copy link
Copy Markdown
Member

Well, it looks like I screwed things up by trying to use github's web UI to resolve the merge conflict. Can you straighten it out? The comments we added were correct, the conflict was with a change that added 'RFC 5233' to the same comment we changed, but I incorporated that change my suggestion that you applied.

Comment thread Lib/email/_parseaddr.py
# The year is between 1969 and 1999 (inclusive).
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.

Why removed this comment? It was accurate.

@@ -0,0 +1,7 @@
Fixed the :mod:`email` module parsing of three digit dates to
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 only change is removing a comment and adding a test. I do not think this NEWS entry is still relevant.

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.

No, the PR got messed up by my using the web to try to resolve the merge conflict, It's current state does not represent its intent, and all should be clear once it gets straightened out.

"Mon, 1 Jan 69 00:00:00 +0000": "1969",
"Mon, 1 Jan 99 00:00:00 +0000": "1999",
# 3-digit year boundary
"Mon, 1 Jan 999 00:00:00 +0000": "2899",
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.

Why the result is not 999?

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.

Because the RFC says it should be interpreted by adding 1900, which is what the PR is going to fix.

@bitdancer
Copy link
Copy Markdown
Member

Well, I'm not enough of a git expert to sort this out in the existing branch, so I built a new PR, #150864, by cherry picking commits from this one. Please verify that I got it right, and I'll merge that one.

I'm going to avoid that web conflict resolution like the plague in the future.

@bitdancer
Copy link
Copy Markdown
Member

Closing this in favor of #150864, since I broke this one :(

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

Labels

awaiting merge stale Stale PR or inactive for long period of time.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants