mirror of
git://git.yoctoproject.org/meta-virtualization.git
synced 2025-07-05 13:25:22 +02:00
xen.inc: python 3.12: fix datetime deprecation warning
Parsing xen.inc with a host distro that provides python 3.12 (such as Ubuntu 24.04) generates the following deprecation warning: 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) This warning comes from the use of datetime.datetime.utcfromtimestamp() in get_build_time_vars. datetime.UTC seems to be a getter wrapper for datetime.timezone.utc, which is already available on older host distro python versions (I have tested only with python 3.10 provided by Ubuntu 22.04) so, opt to use that instead to prevent a breaking change. Signed-off-by: Stanley Stanton <stanley.stanton@taitcommunications.com> Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
This commit is contained in:
parent
b70b45de8c
commit
1640a4dc81
|
@ -151,7 +151,7 @@ def get_build_time_vars(d):
|
|||
source_date_epoch = d.getVar('SOURCE_DATE_EPOCH')
|
||||
if source_date_epoch is not None:
|
||||
import datetime
|
||||
utc_datetime = datetime.datetime.utcfromtimestamp(float(source_date_epoch))
|
||||
utc_datetime = datetime.datetime.fromtimestamp(float(source_date_epoch), datetime.timezone.utc)
|
||||
return " XEN_BUILD_DATE=" + utc_datetime.strftime("%Y-%m-%d") + \
|
||||
" XEN_BUILD_TIME=" + utc_datetime.strftime("%H:%M:%S")
|
||||
return ""
|
||||
|
|
Loading…
Reference in New Issue
Block a user