I'm seeing exec() as a function having the same behavior here from 2.4 to 3.3.
waiting on further detail what I'm missing here
diff --git a/mako/compat.py b/mako/compat.py
index c53091d..2dba143 100644
--- a/mako/compat.py
+++ b/mako/compat.py
@@ -126,36 +126,6 @@
 else:
     callable = callable
 
-################################################
-# cross-compatible exec_()
-# Copyright (c) 2010-2012 Benjamin Peterson
-if py3k:
-    import builtins
-    exec_ = getattr(builtins, "exec")
-
-
-    def reraise(tp, value, tb=None):
-        if value.__traceback__ is not tb:
-            raise value.with_traceback(tb)
-        raise value
-
-
-    print_ = getattr(builtins, "print")
-    del builtins
-
-else:
-    def exec_(code, globs=None, locs=None):
-        """Execute code in a namespace."""
-        if globs is None:
-            frame = sys._getframe(1)
-            globs = frame.f_globals
-            if locs is None:
-                locs = frame.f_locals
-            del frame
-        elif locs is None:
-            locs = globs
-        exec("""exec code in globs, locs""")
-################################################
 
 ################################################
 # cross-compatible metaclass implementation
diff --git a/mako/template.py b/mako/template.py
index acbf05e..9a513e3 100644
--- a/mako/template.py
+++ b/mako/template.py
@@ -639,11 +639,12 @@
         cid = cid.encode()
     module = types.ModuleType(cid)
     code = compile(source, cid, 'exec')
+
+    # this exec() works for 2.4->3.3.
     exec(code, module.__dict__, module.__dict__)
     return (source, module)
 
 def _compile_module_file(template, text, filename, outputpath, module_writer):
-    identifier = template.module_id
     source, lexer = _compile(template, text, filename,
                         generate_magic_comment=True)