From d3dc04b8b7031da1a83f752aa77e23e0919512e5 Mon Sep 17 00:00:00 2001 From: Steven Knight Date: Thu, 21 Mar 2002 18:24:13 +0000 Subject: Make construction variables with a value of 0 work (Anthony Roach) --- src/CHANGES.txt | 5 +++++ src/engine/SCons/Util.py | 2 +- src/engine/SCons/UtilTests.py | 8 ++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 70ba009..97ac313 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -10,6 +10,11 @@ RELEASE 0.06 - + From Anthony Roach: + + - Fix: Construction variables with values of 0 were incorrectly + interpolated as ''. + From Charles Crain: - Fix command generators to expand construction variables. diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py index 04e7e7d..3fb56d9 100644 --- a/src/engine/SCons/Util.py +++ b/src/engine/SCons/Util.py @@ -195,7 +195,7 @@ def scons_subst_list(strSubst, globals, locals, remove=None): key = key[1:-1] try: e = eval(key, globals, locals) - if not e: + if e is None: s = '' elif is_List(e): s = string.join(map(str, e), '\0') diff --git a/src/engine/SCons/UtilTests.py b/src/engine/SCons/UtilTests.py index f3569f0..40553ee 100644 --- a/src/engine/SCons/UtilTests.py +++ b/src/engine/SCons/UtilTests.py @@ -98,6 +98,8 @@ class UtilTestCase(unittest.TestCase): "/bar/ack.cpp", "../foo/ack.c" ])) loc['xxx'] = None + loc['zero'] = 0 + loc['one'] = 1 if os.sep == '/': def cvt(str): @@ -152,6 +154,12 @@ class UtilTestCase(unittest.TestCase): newcom = scons_subst("test $( $xxx $)", loc, {}, re.compile('\$[()]')) assert newcom == cvt("test"), newcom + newcom = scons_subst("test $zero", loc, {}) + assert newcom == cvt("test 0"), newcom + + newcom = scons_subst("test $one", loc, {}) + assert newcom == cvt("test 1"), newcom + newcom = scons_subst("test aXbXcXd", loc, {}, re.compile('X')) assert newcom == cvt("test abcd"), newcom -- cgit v0.12