All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bruce Ashfield <bruce.ashfield@gmail.com>
To: stanley.stanton@taitcommunications.com
Cc: meta-virtualization@lists.yoctoproject.org
Subject: Re: [meta-virtualization] [PATCH v2] xen.inc: python 3.12: fix datetime deprecation warning
Date: Thu, 21 Nov 2024 04:30:58 +0000	[thread overview]
Message-ID: <Zz63giXvpIojHO/S@gmail.com> (raw)
In-Reply-To: <20241119034817.3051733-1-stanley.stanton@taitcommunications.com>

v2 is merged to master. Request cherry-picks to any other
branches of interest.

Bruce

In message: [meta-virtualization] [PATCH v2] xen.inc: python 3.12: fix datetime deprecation warning
on 19/11/2024 Stanley Stanton via lists.yoctoproject.org wrote:

> 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>
> ---
>  recipes-extended/xen/xen.inc | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> 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):
>      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 ""
> -- 
> 2.43.0
> 
> 
> -- 
> 
> This communication is confidential. We only send and receive email on the
> basis of the terms set out at www.taitcommunications.com/email_disclaimer 
> <http://www.taitcommunications.com/email_disclaimer>
> 

> 
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#8976): https://lists.yoctoproject.org/g/meta-virtualization/message/8976
> Mute This Topic: https://lists.yoctoproject.org/mt/109659338/1050810
> Group Owner: meta-virtualization+owner@lists.yoctoproject.org
> Unsubscribe: https://lists.yoctoproject.org/g/meta-virtualization/unsub [bruce.ashfield@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
> 



  reply	other threads:[~2024-11-21  4:31 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-18 22:32 [PATCH] xen.inc: python 3.12: fix datetime deprecation warning Stanley Stanton
2024-11-19  2:30 ` [meta-virtualization] " Bruce Ashfield
     [not found] ` <18093DBF1757132A.18574@lists.yoctoproject.org>
2024-11-19  2:40   ` Bruce Ashfield
2024-11-19  3:48     ` [PATCH v2] " Stanley Stanton
2024-11-21  4:30       ` Bruce Ashfield [this message]
2024-11-25 20:45         ` [meta-virtualization] " Stanley Stanton
2024-11-19  3:49     ` [meta-virtualization] [PATCH] " Stanley Stanton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Zz63giXvpIojHO/S@gmail.com \
    --to=bruce.ashfield@gmail.com \
    --cc=meta-virtualization@lists.yoctoproject.org \
    --cc=stanley.stanton@taitcommunications.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.