python 3.12: utcnow function is deprecated

The following warning is displayed on a system running with Python 3.12:
-------------------
/usr/lib/python3.12/site-packages/ipalib/rpc.py:925: DeprecationWarning:
datetime.utcnow() is deprecated and scheduled for removal in a future
version. Use timezone-aware objects to represent datetimes in UTC:
datetime.now(datetime.UTC).

  timestamp=datetime.datetime.utcnow())
-------------------

Fixes: https://pagure.io/freeipa/issue/9425
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
Reviewed-By: Florence Blanc-Renaud <flo@redhat.com>
This commit is contained in:
Alexander Bokovoy authored and Florence Blanc-Renaud committed 2023-08-09 18:31:03 +02:00
1 parent bbb53a1271
commit 09497d2df0
15 files changed
+36 -31

No files matched your search

+1 -1
View File
@@ -35,7 +35,7 @@ class ExternalCA:
"""
def __init__(self, days=365, key_size=None):
self.now = datetime.datetime.utcnow()
self.now = datetime.datetime.now(tz=datetime.UTC)
self.delta = datetime.timedelta(days=days)
self.ca_key = None
self.ca_public_key = None