Mercurial > genshi > mirror
diff genshi/template/astutil.py @ 879:fe5b8e29fda8 trunk
Looks like the 'decorators' field in the AST was renamed to 'decorator_list' in Python 2.6, so look for both. See #379.
author | cmlenz |
---|---|
date | Thu, 15 Apr 2010 21:38:21 +0000 |
parents | 62c3ffae585d |
children | 28156470fe24 |
line wrap: on
line diff
--- a/genshi/template/astutil.py +++ b/genshi/template/astutil.py @@ -130,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)