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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DeprecationWarning: Parsing dates involving a day of month without a year specified is ambiguious #1020

Closed
kLiHz opened this issue Apr 14, 2024 · 2 comments · Fixed by #1027

Comments

@kLiHz
Copy link

kLiHz commented Apr 14, 2024

Hi, I'm using jupyter-lab with Python 3.13.0a6 and encountered with a deprecation warning.

For example when running jupyter kernelspec list:

$ jupyter kernelspec list
/home/admin/python-3.13.0a6/bin/jupyter-kernelspec:5: DeprecationWarning: Parsing dates involving a day of month without a year specified is ambiguious
and fails to parse leap day. The default behavior will change in Python 3.15
to either always raise an exception or to use a different default year (TBD).
To avoid trouble, add a specific year to the input & format.
See https://github.com/python/cpython/issues/70647.
  from jupyter_client.kernelspecapp import KernelSpecApp
Available kernels:
  deno          /home/admin/.local/share/jupyter/kernels/deno
  javascript    /home/admin/.local/share/jupyter/kernels/javascript
  python3       /home/admin/python-3.13.0a6/share/jupyter/kernels/python3

And about the jupyter-releated packages installed:

$ python3 -m pip list | grep jupyter
jupyter_client            8.6.1
jupyter_core              5.7.2
jupyter-events            0.10.0
jupyter-lsp               2.2.5
jupyter_server            2.14.0
jupyter_server_terminals  0.5.3
jupyterlab                4.1.6
jupyterlab_pygments       0.3.0
jupyterlab_server         2.26.0
@hroncok
Copy link
Contributor

hroncok commented May 16, 2024

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

This seems like we could use a full date here.

@hroncok
Copy link
Contributor

hroncok commented May 16, 2024

E.g. replace it with datetime.strptime("2000-01-01", "%Y-%m-%d")

hroncok added a commit to hroncok/jupyter_client that referenced this issue Jun 10, 2024
    ...
    /usr/lib/python3.13/site-packages/jupyter_client/jsonutil.py:31: in <module>
        datetime.strptime("1", "%d")  # noqa
    /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.

Fixes jupyter#1020
hroncok added a commit to hroncok/ipykernel that referenced this issue Jun 10, 2024
    ...
    /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
hroncok added a commit to hroncok/nbclient that referenced this issue Jun 10, 2024
    ...
    /usr/lib/python3.13/site-packages/nbclient/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
minrk pushed a commit that referenced this issue Sep 17, 2024
...
    /usr/lib/python3.13/site-packages/jupyter_client/jsonutil.py:31: in <module>
        datetime.strptime("1", "%d")  # noqa
    /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.

Fixes #1020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants