You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Pure-Python datetime.fromisoformat() accepts a trailing date-time separator #160850
Title: Pure-Python datetime.fromisoformat() accepts a trailing date-time separator
Bug report
Bug description:
The pure-Python datetime.fromisoformat() (Lib/_pydatetime.py) accepts a string that ends with the date-time separator and has no time after it, and returns midnight. The C implementation raises ValueError:
The same happens with basic and week dates ('20090419T', '2009-W16-7T').
fromisoformat() splits the string at the separator and then only parses the time part if tstr:, so an empty time part makes it fall back to the date-only path. The C version (datetime_fromisoformat()) only takes the date-only path when nothing follows the date (len > separator_location) and otherwise passes the empty time to the time parser, which rejects it.
This matters for PyPy and other implementations that use _pydatetime.
Activity