Skip to content

Commit 5efc419

Browse files
authored
Replace deprecated datetime.datetime.utcfromtimestamp (#448)
It was deprecated in Python 3.12[1]. [1] https://docs.python.org/3.13/library/datetime.html#datetime.datetime.utcfromtimestamp
1 parent 1c1cb17 commit 5efc419

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

amqp/serialization.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import calendar
99
from datetime import datetime
10+
from datetime import timezone
1011
from decimal import Decimal
1112
from io import BytesIO
1213
from struct import pack, unpack_from
@@ -132,7 +133,7 @@ def _read_item(buf, offset):
132133
elif ftype == 'T':
133134
val, = unpack_from('>Q', buf, offset)
134135
offset += 8
135-
val = datetime.utcfromtimestamp(val)
136+
val = datetime.fromtimestamp(val, tz=timezone.utc).replace(tzinfo=None)
136137
# 'V': void
137138
elif ftype == 'V':
138139
val = None
@@ -235,7 +236,8 @@ def loads(format, buf, offset):
235236
bitcount = bits = 0
236237
val, = unpack_from('>Q', buf, offset)
237238
offset += 8
238-
val = datetime.utcfromtimestamp(val)
239+
val = datetime.fromtimestamp(val, tz=timezone.utc).replace(
240+
tzinfo=None)
239241
else:
240242
raise FrameSyntaxError(ILLEGAL_TABLE_TYPE.format(p))
241243
append(val)

0 commit comments

Comments
 (0)