Skip to content

Variables/PackageVariable.py only compares *default* against ENABLE_STRINGS #4702

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dekeonus opened this issue Mar 29, 2025 · 0 comments · Fixed by #4703
Closed

Variables/PackageVariable.py only compares *default* against ENABLE_STRINGS #4702

dekeonus opened this issue Mar 29, 2025 · 0 comments · Fixed by #4703

Comments

@dekeonus
Copy link
Contributor

If SCons.Variables.PackageVariable.PackageVariable is initialised with a default "false" string, it will not be possible to enable the key by using a true boolean nor true string.

Given a SConscript file with something like

vars.Add(PackageVariable("icu", "ICU library location", "no"))

passing scons 'icu=yes' on the command line will not enable the key, only passing a /path will enable the key.
Moreover passing 'icu=yes' will result in a build failure:

scons: *** Path does not exist for variable 'icu': 'no'

This is because the PackageVariable _converter only compares default against ENABLE_STRINGS and so when a cli true value is passed the default value gets returned, however as a string.
The PackageVariable _validator will then parse this default value that should have been a bool as a string and will expect it to be a path.

# Can't return the default if it is one of the enable/disable strings;
# test code expects a bool.
if default in ENABLE_STRINGS:

if this last line is modified to include DISABLE_STRINGS then the PackageVariable module works as expected. i.e.

    if default in ENABLE_STRINGS + DISABLE_STRINGS:

This is with scons-4.9.0 with python-3.12.9 on Gentoo amd64 (both installed by Gentoo's package manager)
Downstream Bug: https://bugs.gentoo.org/950584

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 a pull request may close this issue.

1 participant