Skip to content

Commit

Permalink
Avoid a DeprecationWarning on Python 3.13+
Browse files Browse the repository at this point in the history
    ...
    /usr/lib/python3.13/site-packages/ipykernel/jsonutil.py:29: in <module>
        datetime.strptime("1", "%d")
    /usr/lib64/python3.13/_strptime.py:573: in _strptime_datetime
        tt, fraction, gmtoff_fraction = _strptime(data_string, format)
    /usr/lib64/python3.13/_strptime.py:336: in _strptime
        format_regex = _TimeRE_cache.compile(format)
    /usr/lib64/python3.13/_strptime.py:282: in compile
        return re_compile(self.pattern(format), IGNORECASE)
    /usr/lib64/python3.13/_strptime.py:270: in pattern
        warnings.warn("""\
    E   DeprecationWarning: Parsing dates involving a day of month without a year specified is ambiguious
    E   and fails to parse leap day. The default behavior will change in Python 3.15
    E   to either always raise an exception or to use a different default year (TBD).
    E   To avoid trouble, add a specific year to the input & format.
    E   See python/cpython#70647.

See also jupyter/jupyter_client#1020
  • Loading branch information
hroncok committed Jun 10, 2024
1 parent a7d66ae commit 3e7fb7c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion ipykernel/jsonutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

# holy crap, strptime is not threadsafe.
# Calling it once at import seems to help.
datetime.strptime("1", "%d")
datetime.strptime("2000-01-01", "%Y-%m-%d")

# -----------------------------------------------------------------------------
# Classes and functions
Expand Down

0 comments on commit 3e7fb7c

Please sign in to comment.