Skip to content

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

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 10 commits into
base: main
Choose a base branch
from
Prev Previous commit
moved ParsedateToDatetimeTest
  • Loading branch information
GGyll committed Jul 17, 2025
commit 693bce30d5cadae311b592946e77ba0e1d4f5ed0
17 changes: 0 additions & 17 deletions Lib/test/test_email/test_parsedate_to_datetime.py

This file was deleted.

13 changes: 13 additions & 0 deletions Lib/test/test_email/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,5 +186,18 @@ def test_formatdate_with_localtime(self):
string = utils.formatdate(timeval, localtime=True)
self.assertEqual(string, 'Thu, 01 Dec 2011 18:00:00 +0300')

# Issue #126845: Some edge cases seem to differ from RFC28222 spec
class ParsedateToDatetimeTest(unittest.TestCase):
def test_year_parsing_edge_cases(self):
expectations = {
"Sat, 15 Aug 0001 23:12:09 +0500": "2001",
"Thu, 1 Sep 1 23:12:09 +0800": "2001",
"Thu, 7 Oct 123 23:12:09 +0500": "2023",
"Tue, 17 Nov 2026 12:12:09 +0500": "2026",
}
for input_string, output_string in expectations.items():
with self.subTest(input_string=input_string):
self.assertEqual(str(utils.parsedate_to_datetime(input_string))[:4], output_string)

if __name__ == '__main__':
unittest.main()
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