Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Python 3.11 date.fromisoformat() allows extra formats
Python 3.11 and later allow additional ISO8601 formats in `datetime` module ISO8601 parsing. These formats are not RFC3339 section 5.6 compliant. Especially `datetime.date.fromisoformat()` now allows strings like: * `20230328` (2023-03-28) * `2022W527` (2023-01-01) * `2023-W01` (2023-01-02) * `2023-W13-2` (2023-03-28) Fix by doing a regular expression check before passing the value to `datetime` module. This made the original `.isascii()` check unnecessary. See: * https://docs.python.org/3/whatsnew/3.11.html#datetime * python/cpython@1303f8c927 * https://docs.python.org/3.11/library/datetime.html#datetime.date.fromisoformat * https://www.rfc-editor.org/rfc/rfc3339#section-5.6 Tests covering the invalid values to be sent to json-schema-org/JSON-Schema-Test-Suite Fixes #1056.
- Loading branch information