Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cb35b95

Browse files
committed
Teach the compiler module about augmented assignment to tuple subscripts
1 parent 7580146 commit cb35b95

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

Lib/compiler/pycodegen.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,8 +1045,6 @@ def visitAugSlice(self, node, mode):
10451045
self.emit('STORE_SLICE+%d' % slice)
10461046

10471047
def visitAugSubscript(self, node, mode):
1048-
if len(node.subs) > 1:
1049-
raise SyntaxError, "augmented assignment to tuple is not possible"
10501048
if mode == "load":
10511049
self.visitSubscript(node, 1)
10521050
elif mode == "store":
@@ -1151,10 +1149,10 @@ def visitSubscript(self, node, aug_flag=None):
11511149
self.visit(node.expr)
11521150
for sub in node.subs:
11531151
self.visit(sub)
1154-
if aug_flag:
1155-
self.emit('DUP_TOPX', 2)
11561152
if len(node.subs) > 1:
11571153
self.emit('BUILD_TUPLE', len(node.subs))
1154+
if aug_flag:
1155+
self.emit('DUP_TOPX', 2)
11581156
if node.flags == 'OP_APPLY':
11591157
self.emit('BINARY_SUBSCR')
11601158
elif node.flags == 'OP_ASSIGN':

0 commit comments

Comments
 (0)