Skip to content

avocado-setup: fix UnboundLocalError for env_ver_major in env_check! - #413

Merged
harihare merged 1 commit into
lop-devops:KVMCIfrom
Anushree-Mathur:fix_env_ver_major
Oct 8, 2026
Merged

harihare merged 1 commit into
lop-devops:KVMCIfrom
Anushree-Mathur:fix_env_ver_major

Conversation

@Anushree-Mathur

Copy link
Copy Markdown
Contributor

env_ver_major was used before being assigned because env_ver was being truncated to just the major part before env_ver_full was derived, leaving env_ver_full with no minor version info and env_ver_major never set.

Fix by deriving both env_ver_full and env_ver_major from the original env_ver before any truncation, and removing the now-dead else fallback block that redundantly reassigned env_ver_major.

Signed-off-by: Anushree-Mathur anushree.mathur@linux.ibm.com

env_ver_major was used before being assigned because env_ver was
being truncated to just the major part before env_ver_full was
derived, leaving env_ver_full with no minor version info and
env_ver_major never set.

Fix by deriving both env_ver_full and env_ver_major from the
original env_ver before any truncation, and removing the now-dead
else fallback block that redundantly reassigned env_ver_major.

Signed-off-by: Anushree-Mathur <anushree.mathur@linux.ibm.com>
@Anushree-Mathur

Copy link
Copy Markdown
Contributor Author
Before applying the patch:

 python3 ./avocado-setup.py --bootstrap --enable-kvm
04:29:01 INFO    : Env Config: /root/tests/config/wrapper/env.conf
04:29:01 INFO    : No Run Config: /root/tests/config/wrapper/no_run_tests.conf
04:29:01 INFO    : Check for environment
Traceback (most recent call last):
  File "/root/tests/./avocado-setup.py", line 803, in <module>
    env_check(args.enable_kvm)
  File "/root/tests/./avocado-setup.py", line 186, in env_check
    elif CONFIGFILE.has_section('deps_%s_%s' % (env_ver_major, env_type)):
                                                ^^^^^^^^^^^^^
UnboundLocalError: cannot access local variable 'env_ver_major' where it is not associated with a value

After applying the patch:

python3 ./avocado-setup.py --bootstrap --enable-kvm
04:31:18 INFO    : Env Config: /root/tests/config/wrapper/env.conf
04:31:18 INFO    : No Run Config: /root/tests/config/wrapper/no_run_tests.conf
04:31:18 INFO    : Check for environment
04:31:18 ERROR   : Please install following dependancy packages gcc python3-devel xz-devel numactl policycoreutils-python-utils openssl-devel python3-netifaces

@harihare harihare left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@harihare
harihare merged commit 9561e2b into lop-devops:KVMCI Oct 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants