Mercurial > genshi > genshi-test
diff genshi/template/astutil.py @ 879:27d210790d27
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 | 9598353ed630 |
children | fc1e28cb0bee |
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)