Commit 06c5a516e7 for bind

commit 06c5a516e7f4c4c5d736c1ace3d783b193af3326
Author: Michal Nowak <mnowak@isc.org>
Date:   Fri Oct 9 14:14:59 2026 +0000

    Use datetime.UTC in the system tests

    Python 3.11, now the minimum for the system tests, provides
    datetime.UTC as a shorter alias for datetime.timezone.utc.

    Assisted-by: Claude:claude-opus-5-5

diff --git a/bin/tests/system/dnssec_bypass/tests_bypass.py b/bin/tests/system/dnssec_bypass/tests_bypass.py
index f8aa692750..d634ed45a4 100644
--- a/bin/tests/system/dnssec_bypass/tests_bypass.py
+++ b/bin/tests/system/dnssec_bypass/tests_bypass.py
@@ -9,7 +9,7 @@
 # See the COPYRIGHT file distributed with this work for additional
 # information regarding copyright ownership.

-from datetime import datetime, timedelta, timezone
+from datetime import UTC, datetime, timedelta

 import shutil

@@ -72,7 +72,7 @@ def bootstrap():

         # Sign zone.
         isctest.log.info(f"{zone}: sign zone")
-        now = datetime.now(timezone.utc)
+        now = datetime.now(UTC)
         inception = now - timedelta(hours=1)
         expiration = now + timedelta(days=30)

diff --git a/bin/tests/system/dnssec_py/ans4/noqname_mismatch.py b/bin/tests/system/dnssec_py/ans4/noqname_mismatch.py
index 0c6c3ce9b1..1d766f48a5 100644
--- a/bin/tests/system/dnssec_py/ans4/noqname_mismatch.py
+++ b/bin/tests/system/dnssec_py/ans4/noqname_mismatch.py
@@ -18,7 +18,7 @@ which proof to cache (#5985, #6369).

 from collections.abc import AsyncGenerator
 from dataclasses import dataclass
-from datetime import datetime, timedelta, timezone
+from datetime import UTC, datetime, timedelta
 from pathlib import Path

 import base64
@@ -126,7 +126,7 @@ def soa_rrset(zone: str) -> dns.rrset.RRset:
 def garbage_rrsig(
     owner: str, covered: dns.rdatatype.RdataType, labels: int, signer: str
 ) -> dns.rrset.RRset:
-    now = datetime.now(timezone.utc)
+    now = datetime.now(UTC)
     inception = (now - timedelta(hours=1)).strftime("%Y%m%d%H%M%S")
     expiration = (now + timedelta(days=1)).strftime("%Y%m%d%H%M%S")
     signature = base64.b64encode(bytes(64)).decode("ascii")
diff --git a/bin/tests/system/isctest/kasp.py b/bin/tests/system/isctest/kasp.py
index 0837d09df9..68f74297b3 100644
--- a/bin/tests/system/isctest/kasp.py
+++ b/bin/tests/system/isctest/kasp.py
@@ -10,7 +10,7 @@
 # information regarding copyright ownership.

 from dataclasses import dataclass
-from datetime import datetime, timedelta, timezone
+from datetime import UTC, datetime, timedelta
 from functools import total_ordering
 from pathlib import Path
 from re import compile as Re
@@ -130,9 +130,7 @@ class KeyTimingMetadata:
     def __init__(self, timestamp: str):
         if int(timestamp) <= 0:
             raise ValueError(f'invalid timing metadata value: "{timestamp}"')
-        self.value = datetime.strptime(timestamp, self.FORMAT).replace(
-            tzinfo=timezone.utc
-        )
+        self.value = datetime.strptime(timestamp, self.FORMAT).replace(tzinfo=UTC)

     def __repr__(self):
         return self.value.strftime(self.FORMAT)
@@ -173,7 +171,7 @@ class KeyTimingMetadata:
     @staticmethod
     def now() -> "KeyTimingMetadata":
         result = KeyTimingMetadata.__new__(KeyTimingMetadata)
-        result.value = datetime.now(timezone.utc)
+        result.value = datetime.now(UTC)
         return result


diff --git a/bin/tests/system/statschannel/generic.py b/bin/tests/system/statschannel/generic.py
index d052076923..00dc6dd40f 100644
--- a/bin/tests/system/statschannel/generic.py
+++ b/bin/tests/system/statschannel/generic.py
@@ -10,7 +10,7 @@
 # information regarding copyright ownership.

 from collections import defaultdict
-from datetime import datetime, timedelta, timezone
+from datetime import UTC, datetime, timedelta
 from itertools import count
 from time import sleep

@@ -27,7 +27,7 @@ FMT = "%Y-%m-%dT%H:%M:%S%z"
 # The constants were taken from BIND 9 source code (lib/dns/zone.c)
 max_refresh = timedelta(seconds=2419200)  # 4 weeks
 max_expires = timedelta(seconds=14515200)  # 24 weeks
-dayzero = datetime.fromtimestamp(0, timezone.utc).replace(microsecond=0)
+dayzero = datetime.fromtimestamp(0, UTC).replace(microsecond=0)

 # Wait for the secondary zone files to appear to extract their mtime
 MAX_SECONDARY_ZONE_WAITTIME_SEC = 5
@@ -51,7 +51,7 @@ def check_loaded(loaded, expected, now):


 def check_zone_timers(loaded, expires, refresh, loaded_exp):
-    now = datetime.now(timezone.utc).replace(microsecond=0)
+    now = datetime.now(UTC).replace(microsecond=0)
     # Sanity checks the zone timers values
     if expires is not None:
         check_expires(expires, now, now + max_expires)
@@ -80,7 +80,7 @@ def zone_mtime(zonedir, name):
     except FileNotFoundError:
         return dayzero

-    mtime = datetime.fromtimestamp(si.st_mtime, timezone.utc).replace(microsecond=0)
+    mtime = datetime.fromtimestamp(si.st_mtime, UTC).replace(microsecond=0)

     return mtime

diff --git a/pyproject.toml b/pyproject.toml
index 49f0178327..c3cb241d36 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -109,6 +109,8 @@ lint.select = [
   "UP007",
   "UP035",
   "UP045",
+  # datetime.UTC alias
+  "UP017",
   # f-strings
   "UP031",
   "UP032",