public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* Fix deprecated utcnow() usage in build-many-glibcs.py
@ 2024-01-09 21:39 Joseph Myers
  2024-01-10 10:41 ` Florian Weimer
  0 siblings, 1 reply; 2+ messages in thread
From: Joseph Myers @ 2024-01-09 21:39 UTC (permalink / raw)
  To: libc-alpha

Running build-many-glibcs.py with Python 3.12 or later produces a
warning:

build-many-glibcs.py:566: DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC).
  build_time = datetime.datetime.utcnow()

Replace with datetime.datetime.now(datetime.timezone.utc) (the
datetime.UTC constant is new in 3.11, so not suitable for use in this
script at present).

diff --git a/scripts/build-many-glibcs.py b/scripts/build-many-glibcs.py
index 7e0b90be89..87a42e4aef 100755
--- a/scripts/build-many-glibcs.py
+++ b/scripts/build-many-glibcs.py
@@ -563,7 +563,7 @@ class Context(object):
                 print(config.name, config.compiler.name)
             return
         self.clear_last_build_state(action)
-        build_time = datetime.datetime.utcnow()
+        build_time = datetime.datetime.now(datetime.timezone.utc)
         if action == 'host-libraries':
             build_components = ('gmp', 'mpfr', 'mpc')
             old_components = ()

-- 
Joseph S. Myers
josmyers@redhat.com


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Fix deprecated utcnow() usage in build-many-glibcs.py
  2024-01-09 21:39 Fix deprecated utcnow() usage in build-many-glibcs.py Joseph Myers
@ 2024-01-10 10:41 ` Florian Weimer
  0 siblings, 0 replies; 2+ messages in thread
From: Florian Weimer @ 2024-01-10 10:41 UTC (permalink / raw)
  To: Joseph Myers; +Cc: libc-alpha

* Joseph Myers:

> Running build-many-glibcs.py with Python 3.12 or later produces a
> warning:
>
> build-many-glibcs.py:566: DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC).
>   build_time = datetime.datetime.utcnow()
>
> Replace with datetime.datetime.now(datetime.timezone.utc) (the
> datetime.UTC constant is new in 3.11, so not suitable for use in this
> script at present).
>
> diff --git a/scripts/build-many-glibcs.py b/scripts/build-many-glibcs.py
> index 7e0b90be89..87a42e4aef 100755
> --- a/scripts/build-many-glibcs.py
> +++ b/scripts/build-many-glibcs.py
> @@ -563,7 +563,7 @@ class Context(object):
>                  print(config.name, config.compiler.name)
>              return
>          self.clear_last_build_state(action)
> -        build_time = datetime.datetime.utcnow()
> +        build_time = datetime.datetime.now(datetime.timezone.utc)
>          if action == 'host-libraries':
>              build_components = ('gmp', 'mpfr', 'mpc')
>              old_components = ()

Double-checked that this works with Python 3.6, looks good, thanks.

Florian


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-01-10 10:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-09 21:39 Fix deprecated utcnow() usage in build-many-glibcs.py Joseph Myers
2024-01-10 10:41 ` Florian Weimer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).