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
When checking the EBNF rules, all parts of the timestamp must be with or without separators. A mix of formats is not allowed.
I haven't checked for other basic and extended format mixes.
My CI checked many Python versions and platforms. Here a failed CI pipeline, shows a correct implementation. A successful pipeline denotes a buggy Python version.
All these should be rejected by fromisoformat().
I can report however, that removing just a single dash or a single colon from the date or time is properly rejected.
It is worth noting, the test_datetime defined within datetimetester.py test assumes inconsistent typing is acceptable. For example, '20250102T03:04:05,6' is considered an acceptable string to the datetime.isoformat() function.
Bug report
Bug description:
Since Python 3.11,
datetime.fromisoformat(...)
accepts invalid timestamps. The same code was tested in many Python versions via GitHub Actions:Wrong format:
2024-01-17T15:21:00-0800
Fixed format:
2024-01-17T15:21:00-08:00
Python code to check:
ISO 8601 defines 2 formats:
When checking the EBNF rules, all parts of the timestamp must be with or without separators. A mix of formats is not allowed.
I haven't checked for other basic and extended format mixes.
My CI checked many Python versions and platforms. Here a failed CI pipeline, shows a correct implementation. A successful pipeline denotes a buggy Python version.
Other resources:
datetime.datetime.fromisoformat
#107791CPython versions tested on:
3.8, 3.9, 3.10, 3.11, 3.12, 3.13
Operating systems tested on:
Linux, macOS, Windows
The text was updated successfully, but these errors were encountered: