Mercurial > genshi > genshi-test
comparison 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 |
comparison
equal
deleted
inserted
replaced
878:abfabaea906f | 879:27d210790d27 |
---|---|
128 else: | 128 else: |
129 first = False | 129 first = False |
130 self._write('**' + node.kwarg) | 130 self._write('**' + node.kwarg) |
131 | 131 |
132 # FunctionDef(identifier name, arguments args, | 132 # FunctionDef(identifier name, arguments args, |
133 # stmt* body, expr* decorators) | 133 # stmt* body, expr* decorator_list) |
134 def visit_FunctionDef(self, node): | 134 def visit_FunctionDef(self, node): |
135 for decorator in getattr(node, 'decorators', ()): | 135 decarators = () |
136 if hasattr(node, 'decorator_list'): | |
137 decorators = getattr(node, 'decorator_list') | |
138 else: # different name in earlier Python versions | |
139 decorators = getattr(node, 'decorators', ()) | |
140 for decorator in decorators: | |
136 self._new_line() | 141 self._new_line() |
137 self._write('@') | 142 self._write('@') |
138 self.visit(decorator) | 143 self.visit(decorator) |
139 self._new_line() | 144 self._new_line() |
140 self._write('def ' + node.name + '(') | 145 self._write('def ' + node.name + '(') |