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()

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
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

pip install -e .
parse_log_pytest
pytest
Markdown>=2.0.1 pygments pytest
apt-get update apt-get install -y gcc
3.9
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
-e git+https://github.com/CheetahTemplate3/cheetah3.git@01eaf9e0d4e319d465443d50ad850b849d53b760#egg=CT3
exceptiongroup @ file:///croot/exceptiongroup_1706031385326/work
importlib_metadata==8.6.1
iniconfig @ file:///home/linux1/recipes/ci/iniconfig_1610983019677/work
Markdown==3.7
packaging @ file:///croot/packaging_1734472117206/work
pluggy @ file:///croot/pluggy_1733169602837/work
Pygments==2.19.1
pytest @ file:///croot/pytest_1738938843180/work
tomli @ file:///opt/conda/conda-bld/tomli_1657175507142/work
zipp==3.21.0

name: cheetah3
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - exceptiongroup=1.2.0=py39h06a4308_0
  - iniconfig=1.1.1=pyhd3eb1b0_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=3.0.16=h5eee18b_0
  - packaging=24.2=py39h06a4308_0
  - pip=25.0=py39h06a4308_0
  - pluggy=1.5.0=py39h06a4308_0
  - pytest=8.3.4=py39h06a4308_0
  - python=3.9.21=he870216_1
  - readline=8.2=h5eee18b_0
  - setuptools=75.8.0=py39h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - tomli=2.0.1=py39h06a4308_0
  - tzdata=2025a=h04d1e81_0
  - wheel=0.45.1=py39h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - importlib-metadata==8.6.1
      - markdown==3.7
      - pygments==2.19.1
      - zipp==3.21.0
prefix: /opt/conda/envs/cheetah3

Cheetah/Tests/Template.py::MultipleInheritanceSupport::runTest
Cheetah/Tests/Template.py::ClassMethods_compile::test_baseclassArg Cheetah/Tests/Template.py::ClassMethods_compile::test_basicUsage Cheetah/Tests/Template.py::ClassMethods_compile::test_classNameArg Cheetah/Tests/Template.py::ClassMethods_compile::test_compilationCache Cheetah/Tests/Template.py::ClassMethods_compile::test_keepRefToGeneratedCodeArg Cheetah/Tests/Template.py::ClassMethods_compile::test_mainMethodNameArg Cheetah/Tests/Template.py::ClassMethods_compile::test_moduleFileCaching Cheetah/Tests/Template.py::ClassMethods_compile::test_moduleGlobalsArg Cheetah/Tests/Template.py::ClassMethods_compile::test_moduleNameArg Cheetah/Tests/Template.py::ClassMethods_subclass::test_basicUsage Cheetah/Tests/Template.py::Preprocessors::test_basicUsage1 Cheetah/Tests/Template.py::Preprocessors::test_complexUsage Cheetah/Tests/Template.py::Preprocessors::test_i18n Cheetah/Tests/Template.py::Preprocessors::test_normalizePreprocessorArgVariants Cheetah/Tests/Template.py::TryExceptImportTest::test_FailCase Cheetah/Tests/Template.py::ClassMethodSupport::test_BasicDecorator Cheetah/Tests/Template.py::StaticMethodSupport::test_BasicDecorator Cheetah/Tests/Template.py::SubclassSearchListTest::runTest
Cheetah/Compiler.py
Cheetah/Compiler.py