diff options
author | anatoly techtonik <techtonik@gmail.com> | 2012-12-19 19:22:47 (GMT) |
---|---|---|
committer | anatoly techtonik <techtonik@gmail.com> | 2012-12-19 19:22:47 (GMT) |
commit | 30da57759fda031e95552e6b90fefa4252f90cad (patch) | |
tree | edbc4599bae12cfb31e97f752e856aa173d32dc5 /QMTest | |
parent | 02cae725ed116ae6cd996fe3bf5888f7f8f61b97 (diff) | |
download | SCons-30da57759fda031e95552e6b90fefa4252f90cad.zip SCons-30da57759fda031e95552e6b90fefa4252f90cad.tar.gz SCons-30da57759fda031e95552e6b90fefa4252f90cad.tar.bz2 |
TestCmd.py: Delay cleanup registration with atexit to avoid exessive
tracebacks when Import fails because of missing pywin32
modules (see http://bugs.python.org/issue16718)
Diffstat (limited to 'QMTest')
-rw-r--r-- | QMTest/TestCmd.py | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/QMTest/TestCmd.py b/QMTest/TestCmd.py index 0c42ab5..911e361 100644 --- a/QMTest/TestCmd.py +++ b/QMTest/TestCmd.py @@ -363,18 +363,6 @@ else: re_space = re.compile('\s') -_Cleanup = [] - -def _clean(): - global _Cleanup - cleanlist = [ c for c in _Cleanup if c ] - del _Cleanup[:] - cleanlist.reverse() - for test in cleanlist: - test.cleanup() - -atexit.register(_clean) - def _caller(tblist, skip): string = "" arr = [] @@ -828,6 +816,17 @@ def send_all(p, data): raise Exception(disconnect_message) data = memoryview(data)[sent:] +_Cleanup = [] + +def _clean(): + global _Cleanup + cleanlist = [ c for c in _Cleanup if c ] + del _Cleanup[:] + cleanlist.reverse() + for test in cleanlist: + test.cleanup() + +atexit.register(_clean) class TestCmd(object): @@ -954,11 +953,9 @@ class TestCmd(object): shutil.rmtree(dir, ignore_errors = 1) self._dirlist = [] - try: global _Cleanup - _Cleanup.remove(self) - except (AttributeError, ValueError): - pass + if self in _Cleanup: + _Cleanup.remove(self) def command_args(self, program = None, interpreter = None, @@ -1513,10 +1510,9 @@ class TestCmd(object): # self._dirlist.append(path) + global _Cleanup - try: - _Cleanup.index(self) - except ValueError: + if self not in _Cleanup: _Cleanup.append(self) return path |