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:
datetime.fromisoformat("2024-01-17T15:21:00-0800")
ISO 8601 defines 2 formats:
- basic format (in short: without separators) and
- extended format (with separators).
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:
CPython versions tested on:
3.8, 3.9, 3.10, 3.11, 3.12, 3.13
Operating systems tested on:
Linux, macOS, Windows
Linked PRs
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-0800Fixed format:
2024-01-17T15:21:00-08:00Python 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
Linked PRs
datetime.fromisoformat#131522