Fix stack trace when there's no scanner in an Environment.
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Sat, 5 Mar 2005 04:22:52 +0000 (04:22 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Sat, 5 Mar 2005 04:22:52 +0000 (04:22 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@1243 fdb21ef1-2011-0410-befe-b5e4ea1792b1

src/engine/SCons/Environment.py
src/engine/SCons/EnvironmentTests.py

index 10787a7a524ffb02ff26948c597691b1aa9e890d..2f11f061050e4690e5639a30f544ef5fb4b9c15e 100644 (file)
@@ -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__"
index bfd1262014717511efc9e1272c87e24bcb8b7c56..1772407acd6b84a48802d36cf12a9f9b1a567b4b 100644 (file)
@@ -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