diff options
author | Stanley Stanton <stanley.stanton@taitcommunications.com> | 2024-11-19 16:48:17 +1300 |
---|---|---|
committer | Bruce Ashfield <bruce.ashfield@gmail.com> | 2024-11-21 04:28:56 +0000 |
commit | 1640a4dc81f5d06a1e43c9870fefb2a0d016ef81 (patch) | |
tree | dfa0d5381c86613e1cbef37f2525e02b6842eaf5 | |
parent | b70b45de8c794ad3c7806ff17615d3e2dd2f4fae (diff) | |
download | meta-virtualization-1640a4dc81f5d06a1e43c9870fefb2a0d016ef81.tar.gz |
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>
-rw-r--r-- | recipes-extended/xen/xen.inc | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/recipes-extended/xen/xen.inc b/recipes-extended/xen/xen.inc index dcd281b5..63790f73 100644 --- a/recipes-extended/xen/xen.inc +++ b/recipes-extended/xen/xen.inc | |||
@@ -151,7 +151,7 @@ def get_build_time_vars(d): | |||
151 | source_date_epoch = d.getVar('SOURCE_DATE_EPOCH') | 151 | source_date_epoch = d.getVar('SOURCE_DATE_EPOCH') |
152 | if source_date_epoch is not None: | 152 | if source_date_epoch is not None: |
153 | import datetime | 153 | import datetime |
154 | utc_datetime = datetime.datetime.utcfromtimestamp(float(source_date_epoch)) | 154 | utc_datetime = datetime.datetime.fromtimestamp(float(source_date_epoch), datetime.timezone.utc) |
155 | return " XEN_BUILD_DATE=" + utc_datetime.strftime("%Y-%m-%d") + \ | 155 | return " XEN_BUILD_DATE=" + utc_datetime.strftime("%Y-%m-%d") + \ |
156 | " XEN_BUILD_TIME=" + utc_datetime.strftime("%H:%M:%S") | 156 | " XEN_BUILD_TIME=" + utc_datetime.strftime("%H:%M:%S") |
157 | return "" | 157 | return "" |