Skip to content
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

ListVariable with space parsing broke in 4.8.0 #4585

Closed
kichik opened this issue Aug 11, 2024 · 1 comment
Closed

ListVariable with space parsing broke in 4.8.0 #4585

kichik opened this issue Aug 11, 2024 · 1 comment
Labels
4.8.0 bug Variables Variables() subsystem

Comments

@kichik
Copy link

kichik commented Aug 11, 2024

Our NSIS build broke with 4.8.0: https://github.com/kichik/nsis/actions/runs/10330863317/job/28603274986
Works with SCons 4.7.0: https://github.com/kichik/nsis/actions/runs/9660627425/job/26646616162

The issue can be boiled down to the following:

env = Environment()
opts = Variables()
opts.Add(ListVariable('TEST', 'test', 'none', ['a b', 'c d', 'e']))
opts.Update(env)
print(env["TEST"])

With SCons 4.7.0:

# scons TEST="a b"
scons: Reading SConscript files ...
a b
scons: done reading SConscript files.
scons: Building targets ...
scons: `.' is up to date.
scons: done building targets.

But with SCons 4.8.0:

# scons TEST="a b"
scons: Reading SConscript files ...

scons: *** Invalid value(s) for variable 'TEST': 'a,b'. Valid values are: a b,c d,e,all,none
File "/tmp/a/SConstruct", line 4, in <module>

Required information

@mwichmann mwichmann added bug Variables Variables() subsystem 4.8.0 labels Aug 11, 2024
@mwichmann
Copy link
Collaborator

mwichmann commented Aug 11, 2024

Yes, I can confirm the problem. This was introduced when the validation logic was split from the conversion logic in ListVariable... which may help explain why they were kept together in the first place. In the Variables.Update method, it loops through all the options, subst'ing the value if needed, then calling the converter and storing the result. Then it loops through all the options again, subst'ing the (previously stored) value if needed, then calling the validator and bailing out if there's a problem. Unfortunately, a ListOption doesn't really survive running subst the second time - the converter has already put the value in the right form, a list of strings, thus preserving any embedded spaces, feeding that to subst again turns it back into a string which later gets split. There wasn't a test that tickled this.

A couple of easy approaches break other things - there are a couple of Variables tests that actually depend on the subst before the validator, it turns out.

As an irritating additional problem, the test framework has a bug where it doesn't preserve quoted substrings in the arguments to the instance of SCons it invokes (despite having a piece of code with a comment claiming to "preserve spaces"), so while the CLI sequence scons TEST="a b" delivers the right thing to the Variables code, having a test case do test.run(arguments='TEST="A B"') does not let SCons see a correct command line. I have a fix for that (hopefully preserving what's left of my sanity).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4.8.0 bug Variables Variables() subsystem
Projects
None yet
Development

No branches or pull requests

2 participants