1.1 --- a/common.py Sun Feb 05 18:12:40 2017 +0100
1.2 +++ b/common.py Sun Feb 05 18:17:14 2017 +0100
1.3 @@ -626,12 +626,21 @@
1.4 Process the given slice node 'n' as an operator function invocation.
1.5 """
1.6
1.7 - op = n.flags == "OP_ASSIGN" and "setslice" or "getslice"
1.8 + if n.flags == "OP_ASSIGN": op = "setslice"
1.9 + elif n.flags == "OP_DELETE": op = "delslice"
1.10 + else: op = "getslice"
1.11 +
1.12 invocation = compiler.ast.CallFunc(
1.13 compiler.ast.Name("$op%s" % op),
1.14 [n.expr, n.lower or compiler.ast.Name("None"), n.upper or compiler.ast.Name("None")] +
1.15 (expr and [expr] or [])
1.16 )
1.17 +
1.18 + # Fix parse tree structure.
1.19 +
1.20 + if op == "delslice":
1.21 + invocation = compiler.ast.Discard(invocation)
1.22 +
1.23 return self.process_structure_node(invocation)
1.24
1.25 def process_sliceobj_node(self, n):
1.26 @@ -653,11 +662,20 @@
1.27 Process the given subscript node 'n' as an operator function invocation.
1.28 """
1.29
1.30 - op = n.flags == "OP_ASSIGN" and "setitem" or "getitem"
1.31 + if n.flags == "OP_ASSIGN": op = "setitem"
1.32 + elif n.flags == "OP_DELETE": op = "delitem"
1.33 + else: op = "getitem"
1.34 +
1.35 invocation = compiler.ast.CallFunc(
1.36 compiler.ast.Name("$op%s" % op),
1.37 [n.expr] + list(n.subs) + (expr and [expr] or [])
1.38 )
1.39 +
1.40 + # Fix parse tree structure.
1.41 +
1.42 + if op == "delitem":
1.43 + invocation = compiler.ast.Discard(invocation)
1.44 +
1.45 return self.process_structure_node(invocation)
1.46
1.47 def process_attribute_chain(self, n):