Skip to content

Commit

Permalink
[getlogbook#384] Stop using datetime.utcfromtimestamp() on 3.12+
Browse files Browse the repository at this point in the history
  • Loading branch information
slothkong committed Apr 1, 2024
1 parent e7cc074 commit 445e96f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/logbook/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,10 @@ def convert_time(self, timestamp):
"""Converts the UNIX timestamp of the old record into a
datetime object as used by logbook.
"""
return datetime.utcfromtimestamp(timestamp)
if sys.version_info >= (3, 12):
return datetime.fromtimestamp(timestamp, tz=timezone.utc)
else:
return datetime.utcfromtimestamp(timestamp)

def convert_record(self, old_record):
"""Converts an old logging record into a logbook log record."""
Expand Down

0 comments on commit 445e96f

Please sign in to comment.