From e28e175257be3fb07322bd07c9a658ee65c1db5b Mon Sep 17 00:00:00 2001 From: catborise Date: Thu, 29 Oct 2026 15:18:34 +0300 Subject: [PATCH] fix(nodedevs): the Devices page works on Python 3.12.3 The USB records named a throwaway loop variable `_`, the module's gettext. Python 3.12.3, the Docker image's, inlines comprehensions so that this made `_` an unbound local of the function, and the class labels' `_("Other")` in the next comprehension raised UnboundLocalError: every Devices page failed. Later 3.12 releases do not; the loop variables are now named. --- vrtManager/nodedevs.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/vrtManager/nodedevs.py b/vrtManager/nodedevs.py index a9e199da..2a510e12 100644 --- a/vrtManager/nodedevs.py +++ b/vrtManager/nodedevs.py @@ -203,7 +203,7 @@ def _pci(name, node, nodes, children, vms): # of the bridge class: a host bridge or an LPC controller too "bridge_class": code >> 16 == 0x06, "resources": host_resources(name, nodes, children), - "vms": [vm for vm, pci, _ in vms if address in pci], + "vms": [vm for vm, pci, usb_selectors in vms if address in pci], "physfn": pci_address(physfn.get("domain"), physfn.get("bus"), physfn.get("slot"), physfn.get("function")) if physfn is not None else "", "vfs": len(cap.xpath("capability[@type='virt_functions']/address")), @@ -222,7 +222,7 @@ def _usb(name, node, nodes, children, vms): while parent in nodes and nodes[parent].find("capability").get("type") != "pci": parent = nodes[parent].findtext("parent") controller = nodes[parent].find("capability") if parent in nodes else None - named = [(vm, usb_named(selector, model, (bus, device))) for vm, _, selectors in vms for selector in selectors] + named = [(vm, usb_named(selector, model, (bus, device))) for vm, pci_addresses, selectors in vms for selector in selectors] by_address = sorted({vm for vm, how in named if how == "address"}) return { "bus": bus, @@ -297,7 +297,7 @@ def check_hostdevs(conn, vm, trees): on the host of conn, when they cannot be (hostdev_problems): each definition on its own, as the VM starts from one of them.""" wanted = [(tree, hostdev_users([tree])) for tree in trees] - if not any(pci or usb for _, (pci, usb) in wanted): + if not any(pci or usb for tree, (pci, usb) in wanted): return pci, usb = node_devices(conn) problems = []