Skip to content

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

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

Closed
wants to merge 3 commits into from
Closed
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
Added tests for obscure year inputs to parsedate_to_datetime
  • Loading branch information
GGyll committed May 20, 2025
commit 44084bd488dfaf04375b2b35183ba85470f7627c
18 changes: 18 additions & 0 deletions Lib/test/test_parsedate_to_datetime.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Test to see if parsedate_to_datetime returns the correct year for different digit numbers, adhering to the RFC2822 spec

import unittest
from email.utils import parsedate_to_datetime

class ParsedateToDatetimeTest(unittest.TestCase):
def test(self):
expectations = {
"Sat, 15 Aug 0001 23:12:09 +0500": "0001",
"Thu, 1 Sep 1 23:12:09 +0800": "0001",
"Thu, 7 Oct 123 23:12:09 +0500": "0123",
}
for input_string, output_string in expectations.items():
self.assertEqual(str(parsedate_to_datetime(input_string))[:4], output_string)

if __name__ == '__main__':
unittest.main()

4 changes: 4 additions & 0 deletions issues.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import datetime
from email.utils import parsedate_to_datetime

print(parsedate_to_datetime("Sat, 15 Aug 5000 23:12:09 +0500"))
Loading
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