From 8ead44cb39f7726a695aa21a34820f6d40270829 Mon Sep 17 00:00:00 2001 From: James Falcon Date: Mon, 12 Feb 2024 14:48:01 -0600 Subject: [PATCH 5/6] fix: Address TIOBE abstract interpretation issues (#4866) RH-Author: Ani Sinha RH-MergeRequest: 92: Update pylint version to support python 3.12 RH-Jira: RHEL-44598 RH-Acked-by: Emanuele Giuseppe Esposito RH-Acked-by: Miroslav Rezanina RH-Commit: [2/3] 3ca11206fa159ab45b2db21e78c4cfaf358b1e01 (anisinha/cloud-init) These involve operations on possibly null variables or impossible logic. (cherry picked from commit 5e7ef1032a12267a9a518358fbf89da0a88ddb99) --- cloudinit/config/cc_lxd.py | 2 +- cloudinit/distros/parsers/ifconfig.py | 6 ++++++ cloudinit/util.py | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/cloudinit/config/cc_lxd.py b/cloudinit/config/cc_lxd.py index cb9fc4f3..9f267b4c 100644 --- a/cloudinit/config/cc_lxd.py +++ b/cloudinit/config/cc_lxd.py @@ -432,7 +432,7 @@ def bridge_to_cmd(bridge_cfg): % (bridge_cfg.get("ipv6_address"), bridge_cfg.get("ipv6_netmask")) ) - if bridge_cfg.get("ipv6_nat", "false") == "true": + if bridge_cfg.get("ipv6_nat") == "true": cmd_create.append("ipv6.nat=true") else: diff --git a/cloudinit/distros/parsers/ifconfig.py b/cloudinit/distros/parsers/ifconfig.py index 516b5eb5..d671df1f 100644 --- a/cloudinit/distros/parsers/ifconfig.py +++ b/cloudinit/distros/parsers/ifconfig.py @@ -102,6 +102,7 @@ class Ifconfig: """ ifindex = 0 ifs_by_mac = defaultdict(list) + dev = None for line in text.splitlines(): if len(line) == 0: continue @@ -119,6 +120,11 @@ class Ifconfig: dev.index = ifindex self._ifs_by_name[curif] = dev + if not dev: + # This shouldn't happen with normal ifconfig output, but + # if it does, ensure we don't Traceback + continue + toks = line.lower().strip().split() if len(toks) > 1 and toks[1].startswith("flags="): diff --git a/cloudinit/util.py b/cloudinit/util.py index 3295735c..5f787c5c 100644 --- a/cloudinit/util.py +++ b/cloudinit/util.py @@ -1417,6 +1417,7 @@ def find_devs_with_netbsd( devlist = [] label = None _type = None + mscdlabel_out = "" if criteria: if criteria.startswith("LABEL="): label = criteria.lstrip("LABEL=") -- 2.39.3