Repository: CheetahTemplate3/cheetah3

Issue:
Failing to catch an Exception
Hello,

The following `except` line is expected to be reached as the file `expect_exception_catch` doesn't exist.  Instead, an `indentation error` is raised which was not happening at some point, but even then the ImportError was not catching either.  I think this whole area has been broken since 2, so a legacy issue.
```
#try
    #from lib.expect_exception_catch import as_should_be_ImportError
#except ImportError
    #pass
#end try
```
As a test, the above code is at the top of the template file, and the error is...
```
except ImportError: # generated from line 3, col 1
^
IndentationError: expected an indented block 
```
  
Thanks for picking up Cheetah
  
  
p.s. please keep  pypi release build binaries in sync with the git master branch for the best feedback loop

Discussion:

Patch:
diff --git a/Cheetah/Compiler.py b/Cheetah/Compiler.py
index f1b392d..5629272 100644
--- a/Cheetah/Compiler.py
+++ b/Cheetah/Compiler.py
@@ -1744,11 +1744,12 @@ class ModuleCompiler(SettingsManager, GenUtils):
             #  - We also assume that the final . separates the classname from the
             #    module name.  This might break if people do something really fancy 
             #    with their dots and namespaces.
-            baseclasses = baseClassName.split(',')
-            for klass in baseclasses:
+            baseclasses = []
+            for klass in baseClassName.split(','):
+                klass = klass.strip()
                 chunks = klass.split('.')
                 if len(chunks)==1:
-                    self._getActiveClassCompiler().setBaseClass(klass)
+                    baseclasses.append(klass)
                     if klass not in self.importedVarNames():
                         modName = klass
                         # we assume the class name to be the module name
@@ -1763,7 +1764,7 @@ class ModuleCompiler(SettingsManager, GenUtils):
                         if modName in self.importedVarNames():
                             needToAddImport = False
                             finalBaseClassName = klass.replace(modName+'.', '')
-                            self._getActiveClassCompiler().setBaseClass(finalBaseClassName)
+                            baseclasses.append(finalBaseClassName)
                             break
                         else:
                             modName += '.'+chunk                        
@@ -1773,11 +1774,13 @@ class ModuleCompiler(SettingsManager, GenUtils):
                         if finalClassName != chunks[-2]:
                             # we assume the class name to be the module name
                             modName = '.'.join(chunks)
-                        self._getActiveClassCompiler().setBaseClass(finalClassName)                        
+                        baseclasses.append(finalClassName)
                         importStatement = "from %s import %s" % (modName, finalClassName)
                         self.addImportStatement(importStatement)
                         self.addImportedVarNames( [finalClassName,] ) 
-            
+
+            self._getActiveClassCompiler().setBaseClass(', '.join(baseclasses))
+
     def setCompilerSetting(self, key, valueExpr):
         self.setSetting(key, eval(valueExpr) )
         self._parser.configureParser()


Test patch:
diff --git a/Cheetah/Tests/Boinker.py b/Cheetah/Tests/Boinker.py
new file mode 100644
index 0000000..5f99bc5
--- /dev/null
+++ b/Cheetah/Tests/Boinker.py
@@ -0,0 +1,8 @@
+from __future__ import absolute_import
+
+from Cheetah.Template import Template
+
+
+class Boinker(Template):
+	def boink(self):
+		return [1, 2, 3]
diff --git a/Cheetah/Tests/Pinger.py b/Cheetah/Tests/Pinger.py
new file mode 100644
index 0000000..6b8a488
--- /dev/null
+++ b/Cheetah/Tests/Pinger.py
@@ -0,0 +1,8 @@
+from __future__ import absolute_import
+
+from Cheetah.Template import Template
+
+
+class Pinger(Template):
+	def ping(self):
+		return 'pong'
diff --git a/Cheetah/Tests/Template.py b/Cheetah/Tests/Template.py
index 87d1854..f21949a 100755
--- a/Cheetah/Tests/Template.py
+++ b/Cheetah/Tests/Template.py
@@ -316,25 +316,22 @@ class StaticMethodSupport(TemplateTest):
         except AttributeError as ex:
             self.fail(ex)
 
-class Useless(object):
-    def boink(self):
-        return [1, 2, 3]
 
 class MultipleInheritanceSupport(TemplateTest):
     def runTest(self):
         template = '''
-            #extends Template, Useless
+            #extends Cheetah.Tests.Boinker, Cheetah.Tests.Pinger
             #def foo()
                 #return [4,5] + $boink()
             #end def
         '''
-        template = Template.compile(template,
-                moduleGlobals={'Useless' : Useless},
-                compilerSettings={'autoImportForExtendsDirective' : False})
+
+        template = Template.compile(template)
         template = template()
         result = template.foo()
         assert result == [4, 5, 1, 2, 3], (result, 'Unexpected result')
 
+
 class SubclassSearchListTest(TemplateTest):
     '''
         Verify that if we subclass Template, we can still