gh-89157: Make C and Python implementation of datetime.date.fromisoformat consistent (#131007)

This commit is contained in:
Stan Ulbrych 2025-04-24 15:16:07 +01:00 committed by GitHub
parent 92985e321a
commit 4924bcf0e4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 9 additions and 2 deletions

View file

@ -1050,8 +1050,12 @@ class date:
@classmethod
def fromisoformat(cls, date_string):
"""Construct a date from a string in ISO 8601 format."""
if not isinstance(date_string, str):
raise TypeError('fromisoformat: argument must be str')
raise TypeError('Argument must be a str')
if not date_string.isascii():
raise ValueError('Argument must be an ASCII str')
if len(date_string) not in (7, 8, 10):
raise ValueError(f'Invalid isoformat string: {date_string!r}')