summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2004-05-23 12:13:44 (GMT)
committerSteven Knight <knight@baldmt.com>2004-05-23 12:13:44 (GMT)
commit571b716dd3556cb7307a74684f205705ae46b40e (patch)
tree2c78912009c9c6cb2159523d8e8f0f3f36d5a2cf /src
parentd157a17661410b67ad01cefa8d60b4c265185738 (diff)
downloadSCons-571b716dd3556cb7307a74684f205705ae46b40e.zip
SCons-571b716dd3556cb7307a74684f205705ae46b40e.tar.gz
SCons-571b716dd3556cb7307a74684f205705ae46b40e.tar.bz2
Better handling of syntax errors during variable expansion. (Anthony Roach)
Diffstat (limited to 'src')
-rw-r--r--src/CHANGES.txt3
-rw-r--r--src/engine/SCons/Script/__init__.py6
-rw-r--r--src/engine/SCons/Util.py14
-rw-r--r--src/engine/SCons/UtilTests.py8
4 files changed, 19 insertions, 12 deletions
diff --git a/src/CHANGES.txt b/src/CHANGES.txt
index 57166df..70556c6 100644
--- a/src/CHANGES.txt
+++ b/src/CHANGES.txt
@@ -142,9 +142,6 @@ RELEASE 0.96 - XXX
- Try to find the ICL license file path name in the external environment
and the registry before resorting to the hard-coded path name.
- - Add support for fetching command-line keyword=value arguments in
- order from an ARGLIST list.
-
From Simon Perkins:
- Fix a bug introduced in building shared libraries under MinGW.
diff --git a/src/engine/SCons/Script/__init__.py b/src/engine/SCons/Script/__init__.py
index ab76011..e77297d 100644
--- a/src/engine/SCons/Script/__init__.py
+++ b/src/engine/SCons/Script/__init__.py
@@ -181,9 +181,9 @@ class BuildTask(SCons.Taskmaster.Task):
s = s + ' Stop.'
sys.stderr.write("scons: *** %s\n" % s)
- if tb:
- sys.stderr.write("scons: internal stack trace:\n")
- traceback.print_tb(tb, file=sys.stderr)
+ if tb:
+ sys.stderr.write("scons: internal stack trace:\n")
+ traceback.print_tb(tb, file=sys.stderr)
self.do_failed(status)
diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py
index d2e1d73..8b7207c 100644
--- a/src/engine/SCons/Util.py
+++ b/src/engine/SCons/Util.py
@@ -552,8 +552,11 @@ def scons_subst(strSubst, env, mode=SUBST_RAW, target=None, source=None, dict=No
s = eval(key, self.gvars, lvars)
except (IndexError, NameError, TypeError):
return ''
- except (SyntaxError):
- raise SCons.Errors.UserError, "Syntax error trying to evaluate `%s'" % s
+ except SyntaxError,e:
+ if self.target:
+ raise SCons.Errors.BuildError, (self.target[0], "Syntax error `%s' trying to evaluate `%s'" % (e,s))
+ else:
+ raise SCons.Errors.UserError, "Syntax error `%s' trying to evaluate `%s'" % (e,s)
else:
# Before re-expanding the result, handle
# recursive expansion by copying the local
@@ -695,8 +698,11 @@ def scons_subst_list(strSubst, env, mode=SUBST_RAW, target=None, source=None, di
s = eval(key, self.gvars, lvars)
except (IndexError, NameError, TypeError):
return
- except (SyntaxError):
- raise SCons.Errors.UserError, "Syntax error trying to evaluate `%s'" % s
+ except SyntaxError,e:
+ if self.target:
+ raise SCons.Errors.BuildError, (self.target[0], "Syntax error `%s' trying to evaluate `%s'" % (e,s))
+ else:
+ raise SCons.Errors.UserError, "Syntax error `%s' trying to evaluate `%s'" % (e,s)
else:
# Before re-expanding the result, handle
# recursive expansion by copying the local
diff --git a/src/engine/SCons/UtilTests.py b/src/engine/SCons/UtilTests.py
index 5825406..846aaaa 100644
--- a/src/engine/SCons/UtilTests.py
+++ b/src/engine/SCons/UtilTests.py
@@ -425,7 +425,9 @@ class UtilTestCase(unittest.TestCase):
try:
scons_subst('$foo.bar.3.0', env)
except SCons.Errors.UserError, e:
- assert str(e) == "Syntax error trying to evaluate `$foo.bar.3.0'", e
+ expect1 = "Syntax error `invalid syntax' trying to evaluate `$foo.bar.3.0'"
+ expect2 = "Syntax error `invalid syntax (line 1)' trying to evaluate `$foo.bar.3.0'"
+ assert str(e) in [expect1, expect2], e
else:
raise AssertionError, "did not catch expected UserError"
@@ -787,7 +789,9 @@ class UtilTestCase(unittest.TestCase):
try:
scons_subst_list('$foo.bar.3.0', env)
except SCons.Errors.UserError, e:
- assert str(e) == "Syntax error trying to evaluate `$foo.bar.3.0'", e
+ expect1 = "Syntax error `invalid syntax' trying to evaluate `$foo.bar.3.0'"
+ expect2 = "Syntax error `invalid syntax (line 1)' trying to evaluate `$foo.bar.3.0'"
+ assert str(e) in [expect1, expect2], e
else:
raise AssertionError, "did not catch expected SyntaxError"