Skip to content

Commit

Permalink
Merge pull request SCons#4549 from mwichmann/maint/valid_var_bool
Browse files Browse the repository at this point in the history
Make is_valid_construction_var really be a bool function
  • Loading branch information
bdbaddog authored Jun 3, 2024
2 parents 432ec8a + a217d6a commit 2566498
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 21 deletions.
13 changes: 11 additions & 2 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@

Change Log

NOTE: The 4.0.0 Release of SCons dropped Python 2.7 Support
NOTE: 4.3.0 now requires Python 3.6.0 and above. Python 3.5.x is no longer supported
NOTE: The 4.0.0 release of SCons dropped Python 2.7 support. Use 3.1.2 if
Python 2.7 support is required (but note old SCons releases are unsupported).
NOTE: Since SCons 4.3.0, Python 3.6.0 or above is required.
NOTE: Python 3.6 support is deprecated and will be dropped in a future reease.
python.org no longer supports 3.6 or 3.7, and will drop 3.8 in Oct. 2024.

RELEASE VERSION/DATE TO BE FILLED IN LATER

Expand Down Expand Up @@ -76,6 +79,12 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER
- Framework for scons-time tests adjusted so a path with a long username
Windows has squashed doesn't get re-expanded. Fixes a problem seen
on GitHub Windows runner which uses a name "runneradmin".
- SCons.Environment.is_valid_construction_var() now returns a boolean to
match the convention that functions beginning with "is" have yes/no
answers (previously returned either None or an re.match object).
Now matches the annotation and docstring (which were prematurely
updated in 4.6). All SCons usage except unit test was already fully
consistent with a bool.


RELEASE 4.7.0 - Sun, 17 Mar 2024 17:22:20 -0700
Expand Down
6 changes: 6 additions & 0 deletions RELEASE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ CHANGED/ENHANCED EXISTING FUNCTIONALITY
of CCFLAGS; the latter variable could cause a compiler warning.
- The implementation of Variables was slightly refactored, there should
not be user-visible changes.
- SCons.Environment.is_valid_construction_var() now returns a boolean to
match the convention that functions beginning with "is" have yes/no
answers (previously returned either None or an re.match object).
Now matches the annotation and docstring (which were prematurely
updated in 4.6). All SCons usage except unit test was already fully
consistent with a bool.

FIXES
-----
Expand Down
4 changes: 2 additions & 2 deletions SCons/Environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,9 +512,9 @@ def update(self, mapping) -> None:

_is_valid_var = re.compile(r'[_a-zA-Z]\w*$')

def is_valid_construction_var(varstr) -> bool:
def is_valid_construction_var(varstr: str) -> bool:
"""Return True if *varstr* is a legitimate construction variable."""
return _is_valid_var.match(varstr)
return bool(_is_valid_var.match(varstr))


class SubstitutionEnvironment:
Expand Down
34 changes: 17 additions & 17 deletions SCons/EnvironmentTests.py
Original file line number Diff line number Diff line change
Expand Up @@ -2306,15 +2306,15 @@ def my_depends(target, dependency, tlist=tlist, dlist=dlist) -> None:

exc_caught = None
try:
env.ParseDepends(test.workpath('does_not_exist'), must_exist=1)
env.ParseDepends(test.workpath('does_not_exist'), must_exist=True)
except IOError:
exc_caught = 1
assert exc_caught, "did not catch expected IOError"

del tlist[:]
del dlist[:]

env.ParseDepends('$SINGLE', only_one=1)
env.ParseDepends('$SINGLE', only_one=True)
t = list(map(str, tlist))
d = list(map(str, dlist))
assert t == ['f0'], t
Expand All @@ -2331,7 +2331,7 @@ def my_depends(target, dependency, tlist=tlist, dlist=dlist) -> None:

exc_caught = None
try:
env.ParseDepends(test.workpath('multiple'), only_one=1)
env.ParseDepends(test.workpath('multiple'), only_one=True)
except SCons.Errors.UserError:
exc_caught = 1
assert exc_caught, "did not catch expected UserError"
Expand Down Expand Up @@ -4147,33 +4147,33 @@ class EnvironmentVariableTestCase(unittest.TestCase):
def test_is_valid_construction_var(self) -> None:
"""Testing is_valid_construction_var()"""
r = is_valid_construction_var("_a")
assert r is not None, r
assert r, r
r = is_valid_construction_var("z_")
assert r is not None, r
assert r, r
r = is_valid_construction_var("X_")
assert r is not None, r
assert r, r
r = is_valid_construction_var("2a")
assert r is None, r
assert not r, r
r = is_valid_construction_var("a2_")
assert r is not None, r
assert r, r
r = is_valid_construction_var("/")
assert r is None, r
assert not r, r
r = is_valid_construction_var("_/")
assert r is None, r
assert not r, r
r = is_valid_construction_var("a/")
assert r is None, r
assert not r, r
r = is_valid_construction_var(".b")
assert r is None, r
assert not r, r
r = is_valid_construction_var("_.b")
assert r is None, r
assert not r, r
r = is_valid_construction_var("b1._")
assert r is None, r
assert not r, r
r = is_valid_construction_var("-b")
assert r is None, r
assert not r, r
r = is_valid_construction_var("_-b")
assert r is None, r
assert not r, r
r = is_valid_construction_var("b1-_")
assert r is None, r
assert not r, r



Expand Down

0 comments on commit 2566498

Please sign in to comment.