Mercurial > genshi > mirror
changeset 583:61e072802b62 stable-0.4.x
Ported [696] to 0.4.x branch.
author | cmlenz |
---|---|
date | Wed, 01 Aug 2007 16:23:41 +0000 |
parents | 13244156cf01 |
children | 1d2870364b9b |
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 @@ -673,7 +673,7 @@ def visitAugAssign(self, node): if isinstance(node.node, ast.Name) and (not self.locals - or node.node.name not in flatten(self.locals[-1])): + or 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 @@ -549,6 +549,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"}