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

python3 datetime utcnow deprecation breaks python 3.6 (used on rh8 & ubuntu 18) #1383

Open
petersilva opened this issue Feb 21, 2025 · 1 comment
Labels
bitrot stuff broken because external dependency changes

Comments

@petersilva
Copy link
Contributor

When I run pytest, I get deprecation warnings like so:

...

sarracenia/transfer/s3_test.py: 80 warnings
  /usr/lib/python3/dist-packages/botocore/auth.py:419: DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC).
    datetime_now = datetime.datetime.utcnow()

For telnet, there is no replacement.
If I start up ubuntu 18.04 vm,... which runs python3.6.9 ... and I try:

ubuntu@canny-tick:~$ python3
Python 3.6.9 (default, Mar 10 2023, 16:46:00) 
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import datetime
>>> datetime.datetime.now()
datetime.datetime(2025, 2, 21, 12, 31, 17, 691660)
>>> datetime.datetime.now(datetime.UTC)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'datetime' has no attribute 'UTC'
>>>

so the old code will soon be deprecated, but the new code will not run
on older systems.

@andreleblanc11
Copy link
Member

You can use datetime.datetime.now(datetime.timezone.utc) as an alternative

root@u1804-server:~# python3
Python 3.6.9 (default, Apr 11 2024, 09:35:16)
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import datetime
>>> datetime.datetime.now(datetime.timezone.utc) ; datetime.datetime.utcnow()
datetime.datetime(2025, 2, 21, 18, 26, 14, 751271, tzinfo=datetime.timezone.utc)
datetime.datetime(2025, 2, 21, 18, 26, 14, 751307)

@petersilva petersilva added the bitrot stuff broken because external dependency changes label Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bitrot stuff broken because external dependency changes
Projects
None yet
Development

No branches or pull requests

2 participants