Use of `datetime.datetime.utcfromtimestamp` shows `DeprecationWarning` in Python 3.12
nachomaiz opened this issue · 0 comments
nachomaiz commented
- I have marked all applicable categories:
- exception-raising bug
- visual output bug
- I have visited the source website, and in particular
read the known issues - I have searched through the issue tracker for duplicates
- I have mentioned version numbers, operating system and
environment, where applicable:import tqdm, sys print(tqdm.__version__, sys.version, sys.platform)
Version info
4.66.1 3.12.0 | packaged by conda-forge | (main, Oct 3 2023, 08:26:13) [MSC v.1935 64 bit (AMD64)] win32
Hi! I'm getting this DeprecationWarning
when using tqdm with Python 3.12.
~\venv\Lib\site-packages\tqdm\std.py:580: DeprecationWarning: datetime.datetime.utcfromtimestamp() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.fromtimestamp(timestamp, datetime.UTC).
if rate and total else datetime.utcfromtimestamp(0))
I'm guessing changing this LOC to:
if rate and total else datetime.fromtimestamp(0, timezone.UTC)
Should fix the warning.
Let me know if it would help for me to open a PR with the change.
Thanks!