Fixed some tests for python 2.4.  Disabled a test for 2.4 that does not work because of a python limitation.

--HG--
branch : trunk
diff --git a/jinja2/compiler.py b/jinja2/compiler.py
index efe534b..a52b1c7 100644
--- a/jinja2/compiler.py
+++ b/jinja2/compiler.py
@@ -44,6 +44,15 @@
     dict_item_iter = 'items'
 
 
+# does if 0: dummy(x) get us x into the scope?
+def unoptimize_before_dead_code():
+    x = 42
+    def f():
+        if 0: dummy(x)
+    return f
+unoptimize_before_dead_code = bool(unoptimize_before_dead_code().func_closure)
+
+
 def generate(node, environment, name, filename, stream=None):
     """Generate the python source for a node tree."""
     if not isinstance(node, nodes.Template):
@@ -576,8 +585,10 @@
         # is removed.  If that breaks we have to add a dummy function
         # that just accepts the arguments and does nothing.
         if frame.identifiers.declared:
-            self.writeline('if 0: dummy(%s)' % ', '.join(
-                'l_' + name for name in frame.identifiers.declared))
+            self.writeline('%sdummy(%s)' % (
+                unoptimize_before_dead_code and 'if 0: ' or '',
+                ', '.join('l_' + name for name in frame.identifiers.declared)
+            ))
 
     def push_scope(self, frame, extra_vars=()):
         """This function returns all the shadowed variables in a dict
@@ -739,6 +750,8 @@
         from jinja2.runtime import __all__ as exported
         self.writeline('from __future__ import division')
         self.writeline('from jinja2.runtime import ' + ', '.join(exported))
+        if not unoptimize_before_dead_code:
+            self.writeline('dummy = lambda *x: None')
 
         # do we have an extends tag at all?  If not, we can save some
         # overhead by just not processing any inheritance code.
diff --git a/jinja2/debug.py b/jinja2/debug.py
index 08e828c..c2bd07b 100644
--- a/jinja2/debug.py
+++ b/jinja2/debug.py
@@ -113,7 +113,7 @@
     """Rewrites a syntax error to please traceback systems."""
     error.source = source
     error.translated = True
-    exc_info = (type(error), error, None)
+    exc_info = (error.__class__, error, None)
     filename = error.filename
     if filename is None:
         filename = '<unknown>'
diff --git a/jinja2/testsuite/debug.py b/jinja2/testsuite/debug.py
index ee79498..a0d3ca9 100644
--- a/jinja2/testsuite/debug.py
+++ b/jinja2/testsuite/debug.py
@@ -8,6 +8,7 @@
     :copyright: (c) 2010 by the Jinja Team.
     :license: BSD, see LICENSE for more details.
 """
+import sys
 import unittest
 
 from jinja2.testsuite import JinjaTestCase, filesystem_loader
@@ -19,11 +20,12 @@
 
 class DebugTestCase(JinjaTestCase):
 
-    def test_runtime_error(self):
-        def test():
-            tmpl.render(fail=lambda: 1 / 0)
-        tmpl = env.get_template('broken.html')
-        self.assert_traceback_matches(test, r'''
+    if sys.version_info[:2] != (2, 4):
+        def test_runtime_error(self):
+            def test():
+                tmpl.render(fail=lambda: 1 / 0)
+            tmpl = env.get_template('broken.html')
+            self.assert_traceback_matches(test, r'''
   File ".*?broken.html", line 2, in (top-level template code|<module>)
     \{\{ fail\(\) \}\}
   File ".*?debug.pyc?", line \d+, in <lambda>