[Scons-users] `__lib_either_version_flag` returning `None` triggers `NameError`
Sye van der Veen
syeberman at gmail.com
Sun Apr 14 13:04:45 EDT 2024
I call `SetAllowableExceptions()` in my build files to ensure that I set
all applicable build variables for my targets. I then set variables I don't
currently need to the empty string, to avoid the resulting `NameError`s.
After a recent update to Scons 4.7.0, I was getting a `NameError` stating
that `__libversionflags` was undefined. This variable is implemented as a
function, and the docstring states: `if version_var is not empty, returns
env[flags_var], otherwise returns None`.
https://github.com/SCons/scons/blob/5dd1d9cea01dd639604b6a4cad911ff8437bd961/SCons/Defaults.py#L683
`__libversionflags` is used in `__SHLIBVERSIONFLAGS` and other variables:
```
'__SHLIBVERSIONFLAGS':
'${__libversionflags(__env__,"SHLIBVERSION","_SHLIBVERSIONFLAGS")}'
```
I do not require versioned shared libraries for this particular build, so I
have set ` SHLIBVERSION` to the empty string, which does not trigger a
`NameError`. Unfortunately, this causes `__libversionflags` to return
`None`, which is interpreted as an undefined variable, thus raising a
`NameError`:
https://github.com/SCons/scons/blob/5dd1d9cea01dd639604b6a4cad911ff8437bd961/SCons/Subst.py#L394
I propose that `__libversionflags` be modified to return the empty string
if `version_var` is empty. Note that a similar issue exists for
`__lib_either_version_flag` in the same file; I propose the same change
here too.
Thank you,
Sye van der Veen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist4.pair.net/pipermail/scons-users/attachments/20240414/9cc8e379/attachment.htm>
More information about the Scons-users
mailing list