changeset 684:17f9061d0f74 trunk

Fix one Python 2.3 compatibility in the expression evaluation code. See #177. One more to go, though.
author cmlenz
date Wed, 13 Feb 2008 17:06:19 +0000
parents 0fcb1c0d7c20
children 8ce1a80c8843
files genshi/template/directives.py genshi/template/eval.py
diffstat 2 files changed, 4 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/genshi/template/directives.py
+++ b/genshi/template/directives.py
@@ -22,7 +22,7 @@
 from genshi.core import QName, Stream
 from genshi.path import Path
 from genshi.template.base import TemplateRuntimeError, TemplateSyntaxError, \
-                                 EXPR, _apply_directives
+                                 EXPR, _apply_directives, _ctxt2dict
 from genshi.template.eval import Expression, Suite, ExpressionASTTransformer, \
                                  _parse
 
@@ -725,7 +725,7 @@
     def __call__(self, stream, ctxt, directives):
         frame = {}
         ctxt.push(frame)
-        self.suite.execute(ctxt)
+        self.suite.execute(_ctxt2dict(ctxt))
         for event in _apply_directives(stream, ctxt, directives):
             yield event
         ctxt.pop()
--- a/genshi/template/eval.py
+++ b/genshi/template/eval.py
@@ -439,7 +439,8 @@
         node = node.__class__(*args)
         if lineno is not None:
             node.lineno = lineno
-        if isinstance(node, (ast.Class, ast.Function, ast.GenExpr, ast.Lambda)):
+        if isinstance(node, (ast.Class, ast.Function, ast.Lambda)) or \
+                sys.version_info > (2, 4) and isinstance(node, ast.GenExpr):
             node.filename = '<string>' # workaround for bug in pycodegen
         return node
 
Copyright (C) 2012-2017 Edgewall Software