mirror of
https://github.com/python/cpython.git
synced 2025-08-03 08:34:29 +00:00
GH-90750: Use datetime.fromisocalendar in _strptime (#103802)
Use datetime.fromisocalendar in _strptime This unifies the ISO → Gregorian conversion logic and improves handling of invalid ISO weeks.
This commit is contained in:
parent
b701dce340
commit
a5308e188b
3 changed files with 19 additions and 19 deletions
|
@ -242,6 +242,16 @@ class StrptimeTests(unittest.TestCase):
|
|||
# 5. Julian/ordinal day (%j) is specified with %G, but not %Y
|
||||
with self.assertRaises(ValueError):
|
||||
_strptime._strptime("1999 256", "%G %j")
|
||||
# 6. Invalid ISO weeks
|
||||
invalid_iso_weeks = [
|
||||
"2019-00-1",
|
||||
"2019-54-1",
|
||||
"2021-53-1",
|
||||
]
|
||||
for invalid_iso_dtstr in invalid_iso_weeks:
|
||||
with self.subTest(invalid_iso_dtstr):
|
||||
with self.assertRaises(ValueError):
|
||||
_strptime._strptime(invalid_iso_dtstr, "%G-%V-%u")
|
||||
|
||||
|
||||
def test_strptime_exception_context(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue