Skip to content

Commit 09958cc

Browse files
Initial
1 parent 72e5b25 commit 09958cc

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

Lib/_pydatetime.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,8 +1051,8 @@ def fromordinal(cls, n):
10511051
@classmethod
10521052
def fromisoformat(cls, date_string):
10531053
"""Construct a date from a string in ISO 8601 format."""
1054-
if not isinstance(date_string, str):
1055-
raise TypeError('fromisoformat: argument must be str')
1054+
if not isinstance(date_string, str) or not date_string.isascii():
1055+
raise TypeError('fromisoformat: argument must be an ASCII str')
10561056

10571057
if len(date_string) not in (7, 8, 10):
10581058
raise ValueError(f'Invalid isoformat string: {date_string!r}')
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
The pure Python implementation of :func:`datetime.date.fromisoformat`,
2+
:func:`_pydatetime.date.fromisoformat` now only accepts ASCII strings for
3+
consistency with the C implementation.
4+

0 commit comments

Comments
 (0)