From: Nick Coghlan Date: Tue, 14 Mar 2006 13:21:14 +0000 (+0000) Subject: Teach the compiler module about augmented assignment to tuple subscripts X-Git-Tag: v2.5a0~253 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cb35b95f86062394437da42a3bd78085c4302b78;p=python Teach the compiler module about augmented assignment to tuple subscripts --- diff --git a/Lib/compiler/pycodegen.py b/Lib/compiler/pycodegen.py index 2b3a24f744..f25b3fbf5f 100644 --- a/Lib/compiler/pycodegen.py +++ b/Lib/compiler/pycodegen.py @@ -1045,8 +1045,6 @@ class CodeGenerator: self.emit('STORE_SLICE+%d' % slice) def visitAugSubscript(self, node, mode): - if len(node.subs) > 1: - raise SyntaxError, "augmented assignment to tuple is not possible" if mode == "load": self.visitSubscript(node, 1) elif mode == "store": @@ -1151,10 +1149,10 @@ class CodeGenerator: self.visit(node.expr) for sub in node.subs: self.visit(sub) - if aug_flag: - self.emit('DUP_TOPX', 2) if len(node.subs) > 1: self.emit('BUILD_TUPLE', len(node.subs)) + if aug_flag: + self.emit('DUP_TOPX', 2) if node.flags == 'OP_APPLY': self.emit('BINARY_SUBSCR') elif node.flags == 'OP_ASSIGN':