gmr/pamqp

Deprecation warning about `datetime.utcfromtimestamp`

Closed this issue · 2 comments

decaz commented

Method datetime.utcfromtimestamp is deprecated since version 3.12:

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).

It's used here:

pamqp/pamqp/decode.py

Lines 271 to 283 in 8e72f7b

def timestamp(value: bytes) -> typing.Tuple[int, datetime.datetime]:
"""Decode a timestamp value, returning bytes consumed and the value.
:param value: The binary value to decode
:rtype: :class:`tuple` (:class:`int`, :class:`datetime.datetime`)
:raises ValueError: when the binary data can not be unpacked
"""
try:
temp = common.Struct.timestamp.unpack(value[0:8])
return 8, datetime.datetime.utcfromtimestamp(temp[0])
except TypeError:
raise ValueError('Could not unpack timestamp value')

gmr commented

This was released in 3.3.0.

decaz commented

Thanks!