From 9c83bdfeef71dbba32440ff7f3f63b295425ad35 Mon Sep 17 00:00:00 2001 From: Christian Kujau Date: Tue, 26 Aug 2025 18:06:26 +0200 Subject: [PATCH] xfsprogs: fix utcnow deprecation warning in xfs_scrub_all.py Running xfs_scrub_all under Python 3.13.5 prints the following warning: ---------------------------------------------- $ /usr/sbin/xfs_scrub_all --auto-media-scan-stamp \ /var/lib/xfsprogs/xfs_scrub_all_media.stamp \ --auto-media-scan-interval 1d /usr/sbin/xfs_scrub_all:489: 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). dt = datetime.utcnow() Automatically enabling file data scrub. ---------------------------------------------- Python documentation for context: https://docs.python.org/3/library/datetime.html#datetime.datetime.utcnow Fix this by using datetime.now() instead. NB: Debian/13 ships Python 3.13.5 and has a xfs_scrub_all.timer active, I'd assume that many systems will have that warning now in their logs :-) Signed-off-by: Christian Kujau Reviewed-by: "Darrick J. Wong" --- scrub/xfs_scrub_all.py.in | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/scrub/xfs_scrub_all.py.in b/scrub/xfs_scrub_all.py.in index 515cc144..ce251dae 100644 --- a/scrub/xfs_scrub_all.py.in +++ b/scrub/xfs_scrub_all.py.in @@ -493,12 +493,6 @@ def scan_interval(string): return timedelta(seconds = float(string[:-1])) return timedelta(seconds = int(string)) -def utcnow(): - '''Create a representation of the time right now, in UTC.''' - - dt = datetime.utcnow() - return dt.replace(tzinfo = timezone.utc) - def enable_automatic_media_scan(args): '''Decide if we enable media scanning automatically.''' already_enabled = args.x @@ -515,7 +509,7 @@ def enable_automatic_media_scan(args): else: try: last_run = p.stat().st_mtime - now = utcnow().timestamp() + now = datetime.now(timezone.utc).timestamp() res = last_run + interval.total_seconds() < now except FileNotFoundError: res = True -- 2.47.3