Mercurial > genshi > mirror
changeset 736:a1e8b24bc1bb trunk
Yet another followup fix for #221.
author | cmlenz |
---|---|
date | Thu, 05 Jun 2008 15:46:16 +0000 |
parents | 7e428b22dbaa |
children | ca72e3dc443d |
files | genshi/template/eval.py genshi/template/tests/eval.py |
diffstat | 2 files changed, 5 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/genshi/template/eval.py +++ b/genshi/template/eval.py @@ -22,7 +22,6 @@ except NameError: from sets import ImmutableSet as frozenset from sets import Set as set -import sys from textwrap import dedent from genshi.core import Markup @@ -35,10 +34,10 @@ # Check for a Python 2.4 bug in the eval loop try: - class _FakeMapping(dict): + class _FakeMapping(object): __getitem__ = __setitem__ = lambda *a: None exec 'from sys import *' in {}, _FakeMapping() -except SystemError: +except (SystemError, TypeError): has_star_import_bug = True else: has_star_import_bug = False @@ -485,7 +484,7 @@ if lineno is not None: node.lineno = lineno if isinstance(node, (ast.Class, ast.Function, ast.Lambda)) or \ - sys.version_info > (2, 4) and isinstance(node, ast.GenExpr): + hasattr(ast, 'GenExpr') and isinstance(node, ast.GenExpr): node.filename = '<string>' # workaround for bug in pycodegen return node
--- a/genshi/template/tests/eval.py +++ b/genshi/template/tests/eval.py @@ -18,6 +18,7 @@ import unittest from genshi.core import Markup +from genshi.template.base import Context from genshi.template.eval import Expression, Suite, Undefined, UndefinedError, \ UNDEFINED @@ -573,7 +574,7 @@ def test_import_star(self): suite = Suite("from itertools import *") - data = {} + data = Context() suite.execute(data) assert 'ifilter' in data