Mercurial > genshi > mirror
diff genshi/template/eval.py @ 750:52219748e5c1 trunk
Remove some cruft for supporting Python 2.3.
author | cmlenz |
---|---|
date | Mon, 09 Jun 2008 15:19:59 +0000 |
parents | 6de290dec976 |
children | be88c77839fc |
line wrap: on
line diff
--- a/genshi/template/eval.py +++ b/genshi/template/eval.py @@ -17,11 +17,6 @@ from compiler import ast, parse from compiler.pycodegen import ExpressionCodeGenerator, ModuleCodeGenerator import new -try: - set -except NameError: - from sets import ImmutableSet as frozenset - from sets import Set as set from textwrap import dedent from genshi.core import Markup @@ -40,8 +35,6 @@ exec 'from sys import *' in {}, _FakeMapping() except SystemError: has_star_import_bug = True -except TypeError: - pass # Python 2.3 del _FakeMapping def _star_import_patch(mapping, modname): @@ -484,8 +477,8 @@ node = node.__class__(*args) if lineno is not None: node.lineno = lineno - if isinstance(node, (ast.Class, ast.Function, ast.Lambda)) or \ - hasattr(ast, 'GenExpr') and isinstance(node, ast.GenExpr): + if isinstance(node, (ast.Class, ast.Function, ast.Lambda, + ast.GenExpr)): node.filename = '<string>' # workaround for bug in pycodegen return node @@ -520,13 +513,10 @@ # This is a Python 2.4 bug. Only if we have a broken Python # version we have to apply the hack return node - new_node = ast.Discard(ast.CallFunc( + return ast.Discard(ast.CallFunc( ast.Name('_star_import_patch'), [ast.Name('__data__'), ast.Const(node.modname)], None, None - )) - if hasattr(node, 'lineno'): # No lineno in Python 2.3 - new_node.lineno = node.lineno - return new_node + ), lineno=node.lineno) def visitFunction(self, node): args = []