@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}')
'10000-W25-1', # Invalid year
'2020-W25-0', # Invalid day-of-week
'2020-W25-8', # Invalid day-of-week
+ '٢025-03-09' # Unicode characters
'2009\ud80002\ud80028', # Separators are surrogate codepoints
]
'2009-04-19T03:15:4500:00', # Bad time zone separator
'2009-04-19T03:15:45.123456+24:30', # Invalid time zone offset
'2009-04-19T03:15:45.123456-24:30', # Invalid negative offset
- '2009-04-10ᛇᛇᛇᛇᛇ12:15', # Too many unicode separators
+ '2009-04-10ᛇᛇᛇᛇᛇ12:15', # Unicode chars
'2009-04\ud80010T12:15', # Surrogate char in date
'2009-04-10T12\ud80015', # Surrogate char in time
'2009-04-19T1', # Incomplete hours