From 69255b51d43a8d12096f3e2bf711045567952caa Mon Sep 17 00:00:00 2001 From: stevenknight Date: Sat, 5 Mar 2005 04:22:52 +0000 Subject: [PATCH] Fix stack trace when there's no scanner in an Environment. git-svn-id: http://scons.tigris.org/svn/scons/trunk@1243 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- src/engine/SCons/Environment.py | 6 ++---- src/engine/SCons/EnvironmentTests.py | 6 ++++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/engine/SCons/Environment.py b/src/engine/SCons/Environment.py index 10787a7a..2f11f061 100644 --- a/src/engine/SCons/Environment.py +++ b/src/engine/SCons/Environment.py @@ -569,12 +569,10 @@ class Base(SubstitutionEnvironment): def get_scanner(self, skey): """Find the appropriate scanner given a key (usually a file suffix). - __cacheable__ """ sm = self._gsm() - if sm.has_key(skey): - return sm[skey] - return None + try: return sm[skey] + except (KeyError, TypeError): return None def _smd(self): "__reset_cache__" diff --git a/src/engine/SCons/EnvironmentTests.py b/src/engine/SCons/EnvironmentTests.py index bfd12620..1772407a 100644 --- a/src/engine/SCons/EnvironmentTests.py +++ b/src/engine/SCons/EnvironmentTests.py @@ -708,6 +708,12 @@ class BaseTestCase(unittest.TestCase): suffixes = [".c", ".cc", ".cxx", ".m4", ".m5"] + env = Environment() + try: del env['SCANNERS'] + except KeyError: pass + s = map(env.get_scanner, suffixes) + assert s == [None, None, None, None, None], s + env = Environment(SCANNERS = []) s = map(env.get_scanner, suffixes) assert s == [None, None, None, None, None], s -- 2.26.2