diff options
| author | Steven Knight <knight@baldmt.com> | 2004-07-13 06:13:18 (GMT) |
|---|---|---|
| committer | Steven Knight <knight@baldmt.com> | 2004-07-13 06:13:18 (GMT) |
| commit | 9d2af963f5da83955b06353104b44ad01c86716c (patch) | |
| tree | 62dbd0e4ee82caf4bf3202b8aa8e53be76a9f49a /src/engine/SCons/Script | |
| parent | 321ac083cf44290c309b7021594c3941bfa3f82f (diff) | |
| download | SCons-9d2af963f5da83955b06353104b44ad01c86716c.zip SCons-9d2af963f5da83955b06353104b44ad01c86716c.tar.gz SCons-9d2af963f5da83955b06353104b44ad01c86716c.tar.bz2 | |
Make exception handling thread-safe by using sys.exc_info() instead of sys.exc_{type,value}.
Diffstat (limited to 'src/engine/SCons/Script')
| -rw-r--r-- | src/engine/SCons/Script/SConscript.py | 7 | ||||
| -rw-r--r-- | src/engine/SCons/Script/__init__.py | 18 |
2 files changed, 11 insertions, 14 deletions
diff --git a/src/engine/SCons/Script/SConscript.py b/src/engine/SCons/Script/SConscript.py index 81450e9..074477f 100644 --- a/src/engine/SCons/Script/SConscript.py +++ b/src/engine/SCons/Script/SConscript.py @@ -270,7 +270,8 @@ def SConscript_exception(file=sys.stderr): This will show users who have Python errors where the problem is, without cluttering the output with all of the internal calls leading up to where we exec the SConscript.""" - stack = traceback.extract_tb(sys.exc_traceback) + exc_type, exc_value, exc_tb = sys.exc_info() + stack = traceback.extract_tb(exc_tb) last_text = "" found = 0 i = 0 @@ -284,10 +285,10 @@ def SConscript_exception(file=sys.stderr): # We did not find our exec statement, so this was actually a bug # in SCons itself. Show the whole stack. i = 0 - type = str(sys.exc_type) + type = str(exc_type) if type[:11] == "exceptions.": type = type[11:] - file.write('%s: %s:\n' % (type, sys.exc_value)) + file.write('%s: %s:\n' % (type, exc_value)) for fname, line, func, text in stack[i:]: file.write(' File "%s", line %d:\n' % (fname, line)) file.write(' %s\n' % text) diff --git a/src/engine/SCons/Script/__init__.py b/src/engine/SCons/Script/__init__.py index 2dbb961..87e9602 100644 --- a/src/engine/SCons/Script/__init__.py +++ b/src/engine/SCons/Script/__init__.py @@ -153,18 +153,12 @@ class BuildTask(SCons.Taskmaster.Task): # is to display the various types of Errors and Exceptions # appropriately. status = 2 - e = sys.exc_value - t = sys.exc_type + t, e = self.exc_info()[:2] tb = None - if t is SCons.Errors.TaskmasterException: - # The Taskmaster received an Error or Exception while trying - # to process or build the Nodes and dependencies, which it - # wrapped up for us in the object recorded as the value of - # the Exception, so process the wrapped info instead of the - # TaskmasterException itself. - t = e.type - tb = e.traceback - e = e.value + if t is None: + # The Taskmaster didn't record an exception for this Task; + # see if the sys module has one. + t, e = sys.exc_info()[:2] if t == SCons.Errors.BuildError: sys.stderr.write("scons: *** [%s] %s\n" % (e.node, e.errstr)) @@ -187,6 +181,8 @@ class BuildTask(SCons.Taskmaster.Task): self.do_failed(status) + self.exc_clear() + def make_ready(self): """Make a task ready for execution""" SCons.Taskmaster.Task.make_ready(self) |
