Mercurial > genshi > genshi-test
diff genshi/template/astutil.py @ 902:09cc3627654c experimental-inline
Sync `experimental/inline` branch with [source:trunk@1126].
author | cmlenz |
---|---|
date | Fri, 23 Apr 2010 21:08:26 +0000 |
parents | 1837f39efd6f |
children | 95d62e239f60 |
line wrap: on
line diff
--- a/genshi/template/astutil.py +++ b/genshi/template/astutil.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright (C) 2008 Edgewall Software +# Copyright (C) 2008-2010 Edgewall Software # All rights reserved. # # This software is licensed as described in the file COPYING, which @@ -18,9 +18,6 @@ except ImportError: from genshi.template.ast24 import _ast, parse else: - if not hasattr(_ast, 'AST'): - from genshi.template.astgae import restore - restore(_ast) def parse(source, mode): return compile(source, '', mode, _ast.PyCF_ONLY_AST) @@ -133,9 +130,14 @@ self._write('**' + node.kwarg) # FunctionDef(identifier name, arguments args, - # stmt* body, expr* decorators) + # stmt* body, expr* decorator_list) def visit_FunctionDef(self, node): - for decorator in getattr(node, 'decorators', ()): + decarators = () + if hasattr(node, 'decorator_list'): + decorators = getattr(node, 'decorator_list') + else: # different name in earlier Python versions + decorators = getattr(node, 'decorators', ()) + for decorator in decorators: self._new_line() self._write('@') self.visit(decorator) @@ -654,7 +656,7 @@ self._write(', ') self.visit(dim) else: - raise NotImplemented, 'Slice type not implemented' + raise NotImplemented('Slice type not implemented') _process_slice(node.slice) self._write(']') @@ -740,6 +742,7 @@ visit_TryExcept = _clone visit_TryFinally = _clone visit_Assert = _clone + visit_ExceptHandler = _clone visit_Import = _clone visit_ImportFrom = _clone