Skip to content

Commit 2566498

Browse files
authored
Merge pull request SCons#4549 from mwichmann/maint/valid_var_bool
Make is_valid_construction_var really be a bool function
2 parents 432ec8a + a217d6a commit 2566498

File tree

4 files changed

+36
-21
lines changed

4 files changed

+36
-21
lines changed

CHANGES.txt

+11-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@
44

55
Change Log
66

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

1013
RELEASE VERSION/DATE TO BE FILLED IN LATER
1114

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

8089

8190
RELEASE 4.7.0 - Sun, 17 Mar 2024 17:22:20 -0700

RELEASE.txt

+6
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ CHANGED/ENHANCED EXISTING FUNCTIONALITY
4444
of CCFLAGS; the latter variable could cause a compiler warning.
4545
- The implementation of Variables was slightly refactored, there should
4646
not be user-visible changes.
47+
- SCons.Environment.is_valid_construction_var() now returns a boolean to
48+
match the convention that functions beginning with "is" have yes/no
49+
answers (previously returned either None or an re.match object).
50+
Now matches the annotation and docstring (which were prematurely
51+
updated in 4.6). All SCons usage except unit test was already fully
52+
consistent with a bool.
4753

4854
FIXES
4955
-----

SCons/Environment.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -512,9 +512,9 @@ def update(self, mapping) -> None:
512512

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

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

519519

520520
class SubstitutionEnvironment:

SCons/EnvironmentTests.py

+17-17
Original file line numberDiff line numberDiff line change
@@ -2306,15 +2306,15 @@ def my_depends(target, dependency, tlist=tlist, dlist=dlist) -> None:
23062306

23072307
exc_caught = None
23082308
try:
2309-
env.ParseDepends(test.workpath('does_not_exist'), must_exist=1)
2309+
env.ParseDepends(test.workpath('does_not_exist'), must_exist=True)
23102310
except IOError:
23112311
exc_caught = 1
23122312
assert exc_caught, "did not catch expected IOError"
23132313

23142314
del tlist[:]
23152315
del dlist[:]
23162316

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

23322332
exc_caught = None
23332333
try:
2334-
env.ParseDepends(test.workpath('multiple'), only_one=1)
2334+
env.ParseDepends(test.workpath('multiple'), only_one=True)
23352335
except SCons.Errors.UserError:
23362336
exc_caught = 1
23372337
assert exc_caught, "did not catch expected UserError"
@@ -4147,33 +4147,33 @@ class EnvironmentVariableTestCase(unittest.TestCase):
41474147
def test_is_valid_construction_var(self) -> None:
41484148
"""Testing is_valid_construction_var()"""
41494149
r = is_valid_construction_var("_a")
4150-
assert r is not None, r
4150+
assert r, r
41514151
r = is_valid_construction_var("z_")
4152-
assert r is not None, r
4152+
assert r, r
41534153
r = is_valid_construction_var("X_")
4154-
assert r is not None, r
4154+
assert r, r
41554155
r = is_valid_construction_var("2a")
4156-
assert r is None, r
4156+
assert not r, r
41574157
r = is_valid_construction_var("a2_")
4158-
assert r is not None, r
4158+
assert r, r
41594159
r = is_valid_construction_var("/")
4160-
assert r is None, r
4160+
assert not r, r
41614161
r = is_valid_construction_var("_/")
4162-
assert r is None, r
4162+
assert not r, r
41634163
r = is_valid_construction_var("a/")
4164-
assert r is None, r
4164+
assert not r, r
41654165
r = is_valid_construction_var(".b")
4166-
assert r is None, r
4166+
assert not r, r
41674167
r = is_valid_construction_var("_.b")
4168-
assert r is None, r
4168+
assert not r, r
41694169
r = is_valid_construction_var("b1._")
4170-
assert r is None, r
4170+
assert not r, r
41714171
r = is_valid_construction_var("-b")
4172-
assert r is None, r
4172+
assert not r, r
41734173
r = is_valid_construction_var("_-b")
4174-
assert r is None, r
4174+
assert not r, r
41754175
r = is_valid_construction_var("b1-_")
4176-
assert r is None, r
4176+
assert not r, r
41774177

41784178

41794179

0 commit comments

Comments
 (0)