Skip to content

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

Closed

Description

@dekeonus

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

Activity

  1. added a commit that references this issue on Mar 29, 2025
    a394c8b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions