Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Python 3.11 date.fromisoformat() allows extra formats #1076

Commits on Mar 28, 2023

  1. 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 python-jsonschema#1056.
    jvtm committed Mar 28, 2023
    Configuration menu
    Copy the full SHA
    781f8cd View commit details
    Browse the repository at this point in the history