Mercurial > genshi > mirror
changeset 582:0dc024715f93 trunk
Follow-up fix to [693:694]. Again, thanks to Erik Bray for reporting.
author | cmlenz |
---|---|
date | Wed, 01 Aug 2007 16:22:05 +0000 |
parents | 678278fa92e7 |
children | 94f719af686d |
files | genshi/template/eval.py genshi/template/tests/eval.py |
diffstat | 2 files changed, 11 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/genshi/template/eval.py +++ b/genshi/template/eval.py @@ -655,7 +655,7 @@ def visitAugAssign(self, node): if isinstance(node.node, ast.Name) \ - and node.node.name not in flatten(self.locals[-1]): + and node.node.name not in flatten(self.locals): name = node.node.name node.node = ast.Subscript(ast.Name('data'), 'OP_APPLY', [ast.Const(name)])
--- a/genshi/template/tests/eval.py +++ b/genshi/template/tests/eval.py @@ -558,6 +558,16 @@ x = foo()""").execute(d) self.assertEqual(2, d['x']) + def test_augmented_assign_in_loop_in_def(self): + d = {} + Suite("""def foo(): + i = 0 + for n in range(5): + i += n + return i +x = foo()""").execute(d) + self.assertEqual(10, d['x']) + def test_assign_in_list(self): suite = Suite("[d['k']] = 'foo',; assert d['k'] == 'foo'") d = {"k": "bar"}