mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
gh-89157: Make C and Python implementation of datetime.date.fromisoformat
consistent (#131007)
This commit is contained in:
parent
92985e321a
commit
4924bcf0e4
3 changed files with 9 additions and 2 deletions
|
@ -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}')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue