From 64aa751dd4d1f88a4502681062e9116b6df360f9 Mon Sep 17 00:00:00 2001 From: stevenknight Date: Thu, 21 Mar 2002 18:24:13 +0000 Subject: [PATCH] Make construction variables with a value of 0 work (Anthony Roach) git-svn-id: http://scons.tigris.org/svn/scons/trunk@300 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- 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 70ba0093..97ac3137 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 04e7e7d9..3fb56d96 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 f3569f05..40553eea 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 -- 2.26.2