Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER
- In the SequenceTypes tuple used for dynamic type checks, include
the dict contents views, exclude the dictionary view itself as it
is not an interable sequence type.
- Internal: where the find method on a string was used to determine
if a substring is present, use the more readable "in" and "not in".


RELEASE 4.10.0 - Thu, 02 Oct 2025 11:40:20 -0700
Expand Down
3 changes: 3 additions & 0 deletions RELEASE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ IMPROVEMENTS
documentation: performance improvements (describe the circumstances
under which they would be observed), or major code cleanups

- Internal: where the find method on a string was used to determine
if a substring is present, use the more readable "in" and "not in".

PACKAGING
---------

Expand Down
4 changes: 2 additions & 2 deletions SCons/ActionTests.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ def none(a) -> None:
except SCons.Errors.UserError as e:
s = str(e)
m = 'Invalid command display variable'
assert s.find(m) != -1, 'Unexpected string: %s' % s
assert m in s, f'Unexpected string: {s}'
else:
raise Exception("did not catch expected UserError")

Expand Down Expand Up @@ -540,7 +540,7 @@ def func() -> None:
except SCons.Errors.UserError as e:
s = str(e)
m = 'Cannot have both strfunction and cmdstr args to Action()'
assert s.find(m) != -1, 'Unexpected string: %s' % s
assert m in s, f'Unexpected string: {s}'
else:
raise Exception("did not catch expected UserError")

Expand Down
10 changes: 5 additions & 5 deletions SCons/Platform/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@ def platform_default():
if osname == 'posix':
if sys.platform == 'cygwin':
return 'cygwin'
elif sys.platform.find('irix') != -1:
elif 'irix' in sys.platform:
return 'irix'
elif sys.platform.find('sunos') != -1:
elif 'sunos' in sys.platform:
return 'sunos'
elif sys.platform.find('hp-ux') != -1:
elif 'hp-ux' in sys.platform:
return 'hpux'
elif sys.platform.find('aix') != -1:
elif 'aix' in sys.platform:
return 'aix'
elif sys.platform.find('darwin') != -1:
elif 'darwin' in sys.platform:
return 'darwin'
else:
return 'posix'
Expand Down
4 changes: 2 additions & 2 deletions SCons/Platform/win32.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,10 @@ def piped_spawn(sh, escape, cmd, args, env, stdout, stderr):
stderrRedirected = False
for arg in args:
# are there more possibilities to redirect stdout ?
if arg.find(">", 0, 1) != -1 or arg.find("1>", 0, 2) != -1:
if arg.startswith(">")or arg.startswith("1>"):
stdoutRedirected = True
# are there more possibilities to redirect stderr ?
if arg.find("2>", 0, 2) != -1:
if arg.startswith("2>"):
stderrRedirected = True

# redirect output of non-redirected streams to our tempfiles
Expand Down
4 changes: 2 additions & 2 deletions SCons/Script/Main.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def __init__(self, obj, interval: int=1, file=None, overwrite: bool=False) -> No
self.func = obj
elif SCons.Util.is_List(obj):
self.func = self.spinner
elif obj.find(self.target_string) != -1:
elif self.target_string in obj:
self.func = self.replace_string
else:
self.func = self.string
Expand Down Expand Up @@ -644,7 +644,7 @@ def find_deepest_user_frame(tb):
# of SCons:
for frame in tb:
filename = frame[0]
if filename.find(os.sep+'SCons'+os.sep) == -1:
if f'{os.sep}SCons{os.sep}' not in filename:
return frame
return tb[0]

Expand Down
6 changes: 3 additions & 3 deletions SCons/Subst.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,8 +561,8 @@ def expand(self, s, lvars, within_list):
self.close_strip('$)')
else:
key = s[1:]
if key[0] == '{' or key.find('.') >= 0:
if key[0] == '{':
if key.startswith('{') or '.' in key:
if key.startswith('{'):
key = key[1:-1]

# Store for error messages if we fail to expand the
Expand Down Expand Up @@ -962,7 +962,7 @@ def scons_subst_once(strSubst, env, key):

We do this with some straightforward, brute-force code here...
"""
if isinstance(strSubst, str) and strSubst.find('$') < 0:
if isinstance(strSubst, str) and '$' not in strSubst:
return strSubst

matchlist = ['$' + key, '${' + key + '}']
Expand Down
27 changes: 12 additions & 15 deletions SCons/Tool/hpcxx.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
"""SCons.Tool.hpc++

Tool-specific initialization for c++ on HP/UX.

There normally shouldn't be any need to import this module directly.
It will usually be imported through the generic SCons.Tool.Tool()
selection method.

"""

# MIT License
#
# __COPYRIGHT__
# Copyright The SCons Foundation
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
Expand All @@ -29,9 +20,15 @@
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#

__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
"""SCons.Tool.hpc++

Tool-specific initialization for c++ on HP/UX.

There normally shouldn't be any need to import this module directly.
It will usually be imported through the generic SCons.Tool.Tool()
selection method.
"""

import os.path

Expand Down Expand Up @@ -59,7 +56,7 @@
acc = cc
break


def generate(env) -> None:
"""Add Builders and construction variables for g++ to an Environment."""
cplusplus.generate(env)
Expand All @@ -70,7 +67,7 @@ def generate(env) -> None:
# determine version of aCC
with os.popen(acc + ' -V 2>&1') as p:
line = p.readline().rstrip()
if line.find('aCC: HP ANSI C++') == 0:
if line.startswith('aCC: HP ANSI C++'):
env['CXXVERSION'] = line.split()[-1]

if env['PLATFORM'] == 'cygwin':
Expand Down
2 changes: 1 addition & 1 deletion SCons/Tool/intelc.py
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ class ICLTopDirWarning(SCons.Warnings.SConsWarning):
for ld in [envlicdir, reglicdir]:
# If the string contains an '@', then assume it's a network
# license (port@system) and good by definition.
if ld and (ld.find('@') != -1 or os.path.exists(ld)):
if ld and ('@' in ld or os.path.exists(ld)):
licdir = ld
break
if not licdir:
Expand Down
4 changes: 2 additions & 2 deletions SCons/Tool/midl.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ def midl_emitter(target, source, env):

midlcom = env['MIDLCOM']

if midlcom.find('/proxy') != -1:
if '/proxy' in midlcom:
proxy = base + '_p.c'
targets.append(proxy)
if midlcom.find('/dlldata') != -1:
if '/dlldata' in midlcom:
dlldata = base + '_data.c'
targets.append(dlldata)

Expand Down
4 changes: 2 additions & 2 deletions SCons/Tool/msvsTests.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ def valindex(self,index):
return rv

def key(self,key,sep: str = '\\'):
if key.find(sep) != -1:
if sep in key:
keyname, subkeys = key.split(sep,1)
else:
keyname = key
Expand All @@ -479,7 +479,7 @@ def key(self,key,sep: str = '\\'):
raise SCons.Util.RegError

def addKey(self,name,sep: str = '\\'):
if name.find(sep) != -1:
if sep in name:
keyname, subkeys = name.split(sep, 1)
else:
keyname = name
Expand Down
4 changes: 2 additions & 2 deletions SCons/Tool/tex.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ def check_content_hash(filenode, suffix) -> bool:
if os.path.isfile(target_aux):
with open(target_aux) as f:
content = f.read()
if content.find("bibdata") != -1:
if 'bibdata' in content:
if Verbose:
print("Need to run bibtex on ",auxfilename)
bibfile = env.fs.File(SCons.Util.splitext(target_aux)[0])
Expand All @@ -361,7 +361,7 @@ def check_content_hash(filenode, suffix) -> bool:
if os.path.isfile(target_bcf):
with open(target_bcf) as f:
content = f.read()
if content.find("bibdata") != -1:
if 'bibdata' in content:
if Verbose:
print("Need to run biber on ",bcffilename)
bibfile = env.fs.File(SCons.Util.splitext(target_bcf)[0])
Expand Down
3 changes: 2 additions & 1 deletion test/AS/as-live.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
if not test.detect('AS', 'as'):
test.skip_test("as not found; skipping test\n")

x86 = (sys.platform == 'win32' or sys.platform.find('linux') != -1)
# this is an odd check... linux runs on non-x86 hardware
x86 = (sys.platform == 'win32' or 'linux' in sys.platform)
if not x86:
test.skip_test("skipping as test on non-x86 platform '%s'\n" % sys.platform)

Expand Down
4 changes: 2 additions & 2 deletions test/AS/nasm.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
if not nasm:
test.skip_test('nasm not found; skipping test\n')

if sys.platform.find('linux') == -1:
if 'linux' not in sys.platform:
test.skip_test("skipping test on non-Linux platform '%s'\n" % sys.platform)

try:
Expand Down Expand Up @@ -69,7 +69,7 @@
nasm_format = 'elf'
format_map = {}
for k, v in format_map.items():
if sys.platform.find(k) != -1:
if k in sys.platform:
nasm_format = v
break

Expand Down
4 changes: 2 additions & 2 deletions test/Builder/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@
def buildop(env, source, target):
with open(target[0], 'wb') as outf, open(source[0], 'r') as infp:
for line in inpf.readlines():
if line.find(str(target[0])) == -1:
if target[0] not in line:
outf.write(line)
b1 = Builder(action=buildop, src_suffix='.a', suffix='.b')
%s
env=Environment(tools=[], BUILDERS={'b1':b1, 'b2':b2})
env = Environment(tools=[], BUILDERS={'b1':b1, 'b2':b2})
foo_b = env.b1(source='foo.a')
env.b2(source=foo_b)
"""
Expand Down
2 changes: 1 addition & 1 deletion test/CC/SHCCFLAGS-live.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

if os.name == 'posix':
os.environ['LD_LIBRARY_PATH'] = '.'
if sys.platform.find('irix') > -1:
if 'irix' in sys.platform:
os.environ['LD_LIBRARYN32_PATH'] = '.'

test.write('SConstruct', f"""\
Expand Down
2 changes: 1 addition & 1 deletion test/CC/SHCFLAGS-live.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

if os.name == 'posix':
os.environ['LD_LIBRARY_PATH'] = '.'
if sys.platform.find('irix') > -1:
if 'irix' in sys.platform:
os.environ['LD_LIBRARYN32_PATH'] = '.'

test.write('SConstruct', f"""\
Expand Down
2 changes: 1 addition & 1 deletion test/CPPPATH/match-dir.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
test = TestSCons.TestSCons()

# TODO(sgk): get this to work everywhere by using fake compilers
if sys.platform.find('sunos') != -1:
if 'sunos' in sys.platform:
msg = 'SunOS C compiler does not handle this case; skipping test.\n'
test.skip_test(msg)

Expand Down
2 changes: 1 addition & 1 deletion test/CXX/CXXFLAGS-live.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

if os.name == 'posix':
os.environ['LD_LIBRARY_PATH'] = '.'
if sys.platform.find('irix') > -1:
if 'irix' in sys.platform:
os.environ['LD_LIBRARYN32_PATH'] = '.'

e = test.Environment()
Expand Down
2 changes: 1 addition & 1 deletion test/CXX/SHCCFLAGS-live.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

if os.name == 'posix':
os.environ['LD_LIBRARY_PATH'] = '.'
if sys.platform.find('irix') > -1:
if 'irix' in sys.platform:
os.environ['LD_LIBRARYN32_PATH'] = '.'

test.write('SConstruct', f"""\
Expand Down
2 changes: 1 addition & 1 deletion test/CXX/SHCXXFLAGS-live.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

if os.name == 'posix':
os.environ['LD_LIBRARY_PATH'] = '.'
if sys.platform.find('irix') > -1:
if 'irix' in sys.platform:
os.environ['LD_LIBRARYN32_PATH'] = '.'

test.write('SConstruct', f"""\
Expand Down
2 changes: 1 addition & 1 deletion test/Errors/nonexistent-executable.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
konnte_nicht_gefunden_werden % ('f1', 1),
unspecified % 'f1'
]
elif sys.platform.find('sunos') != -1:
elif 'sunos' in sys.platform:
errs = [
not_found_space % ('f1', 1),
]
Expand Down
14 changes: 6 additions & 8 deletions test/LINK/VersionedLib-VariantDir.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/env python
#
# __COPYRIGHT__
# MIT License
#
# Copyright The SCons Foundation
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
Expand All @@ -20,9 +22,6 @@
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#

__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"

"""
Ensure that SharedLibrary builder with SHLIBVERSION set works with VariantDir.
Expand All @@ -41,8 +40,6 @@
platform = SCons.Platform.platform_default()
tool_list = SCons.Platform.DefaultToolList(platform, env)



test.subdir(['src'])
test.subdir(['src','lib'])
test.subdir(['src','bin'])
Expand All @@ -65,7 +62,8 @@
}
""")

test.write('SConstruct', """
test.write('SConstruct', """\
DefaultEnvironment(tools=[])
env = Environment()
variant = { 'variant_dir' : 'build',
'src_dir' : 'src',
Expand Down Expand Up @@ -96,7 +94,7 @@

if os.name == 'posix':
os.environ['LD_LIBRARY_PATH'] = test.workpath('build/lib')
if sys.platform.find('irix') != -1:
if 'irix' in sys.platform:
os.environ['LD_LIBRARYN32_PATH'] = test.workpath('build/lib')

test.run(program = test.workpath('build/bin/main'))
Expand Down
5 changes: 3 additions & 2 deletions test/LINK/VersionedLib-j2.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@
int main(void) { return foo(); }
""")

test.write('SConstruct', """
test.write('SConstruct', """\
DefaultEnvironment(tools=[])
env = Environment()
env.AppendUnique(LIBPATH = ['.'])
env.Program('main.c', LIBS = ['foo'])
Expand All @@ -77,7 +78,7 @@

if os.name == 'posix':
os.environ['LD_LIBRARY_PATH'] = test.workpath('.')
if sys.platform.find('irix') != -1:
if 'irix' in sys.platform:
os.environ['LD_LIBRARYN32_PATH'] = test.workpath('.')

test.run(program = test.workpath('main'))
Expand Down
Loading
Loading