Skip to content

Fix access to unassigned variable when installing Python < 3.9.1 with using sysroot #3686

Merged
boegel merged 3 commits intoeasybuilders:developfrom
Flamefire:fix-python-before-3.9
May 23, 2025
Merged

Fix access to unassigned variable when installing Python < 3.9.1 with using sysroot #3686
boegel merged 3 commits intoeasybuilders:developfrom
Flamefire:fix-python-before-3.9

Conversation

@Flamefire
Copy link
Copy Markdown
Contributor

if LooseVersion(self.version) >= "3.9.1":
    orig_ld_config_call = "with subprocess.Popen(['/sbin/ldconfig', '-p'],"
if orig_ld_config_call:

This code will crash when the Python version to be installed is less than 3.9.1 as the variable is unbound/unset in that case.
Fix is trivial: Remove the line of the 2nd if as this is the only place where the variable is set

I included 2 other changes suggested by PyLint:

  • Use dict.items instead of iterating over keys and then requesting values
  • Combine nested (single) ifs to remove one level of indentation at the cost of a longer condition

I can remove one or both again but IMO they make sense. At least the former which doesn't has any drawbacks I can see

@Flamefire
Copy link
Copy Markdown
Contributor Author

@boegel is this a candidate for 5.0.1? Excluding the spaces the change is trivial

@boegel boegel added the bug fix label Apr 23, 2025
@boegel boegel added this to the 5.0.1 milestone Apr 23, 2025
@boegel boegel added the EESSI Related to EESSI project label Apr 23, 2025
@Flamefire Flamefire force-pushed the fix-python-before-3.9 branch from 8cbf9de to 7b472c0 Compare May 23, 2025 09:04
Copy link
Copy Markdown
Member

@boegel boegel left a comment

Choose a reason for hiding this comment

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

lgtm

@boegel
Copy link
Copy Markdown
Member

boegel commented May 23, 2025

Test report by @boegel

Overview of tested easyconfigs (in order)

  • SUCCESS Python-2.7.18-GCCcore-12.3.0.eb
  • SUCCESS Python-3.13.1-GCCcore-14.2.0.eb

Build succeeded for 2 out of 2 (2 easyconfigs in total)
node3502.doduo.os - Linux RHEL 9.4, x86_64, AMD EPYC 7552 48-Core Processor (zen2), Python 3.9.18
See https://gist.github.com/boegel/3c86b3d73436a37a282e5285312a14ac for a full test report.

@boegel boegel merged commit d96e5c9 into easybuilders:develop May 23, 2025
17 checks passed
@Flamefire Flamefire deleted the fix-python-before-3.9 branch May 23, 2025 11:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug fix EESSI Related to EESSI project

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants