1.1 --- a/common.py Sun Mar 26 01:48:51 2017 +0100
1.2 +++ b/common.py Sun Mar 26 01:50:19 2017 +0100
1.3 @@ -650,22 +650,22 @@
1.4 def process_slice_node(self, n, expr=None):
1.5
1.6 """
1.7 - Process the given slice node 'n' as an operator function invocation.
1.8 + Process the given slice node 'n' as a method invocation.
1.9 """
1.10
1.11 - if n.flags == "OP_ASSIGN": op = "setslice"
1.12 - elif n.flags == "OP_DELETE": op = "delslice"
1.13 - else: op = "getslice"
1.14 + if n.flags == "OP_ASSIGN": op = "__setslice__"
1.15 + elif n.flags == "OP_DELETE": op = "__delslice__"
1.16 + else: op = "__getslice__"
1.17
1.18 invocation = compiler.ast.CallFunc(
1.19 - compiler.ast.Name("$op%s" % op),
1.20 - [n.expr, n.lower or compiler.ast.Name("None"), n.upper or compiler.ast.Name("None")] +
1.21 + compiler.ast.Getattr(n.expr, op),
1.22 + [n.lower or compiler.ast.Name("None"), n.upper or compiler.ast.Name("None")] +
1.23 (expr and [expr] or [])
1.24 )
1.25
1.26 # Fix parse tree structure.
1.27
1.28 - if op == "delslice":
1.29 + if op == "__delslice__":
1.30 invocation = compiler.ast.Discard(invocation)
1.31
1.32 return self.process_structure_node(invocation)
1.33 @@ -686,21 +686,21 @@
1.34 def process_subscript_node(self, n, expr=None):
1.35
1.36 """
1.37 - Process the given subscript node 'n' as an operator function invocation.
1.38 + Process the given subscript node 'n' as a method invocation.
1.39 """
1.40
1.41 - if n.flags == "OP_ASSIGN": op = "setitem"
1.42 - elif n.flags == "OP_DELETE": op = "delitem"
1.43 - else: op = "getitem"
1.44 + if n.flags == "OP_ASSIGN": op = "__setitem__"
1.45 + elif n.flags == "OP_DELETE": op = "__delitem__"
1.46 + else: op = "__getitem__"
1.47
1.48 invocation = compiler.ast.CallFunc(
1.49 - compiler.ast.Name("$op%s" % op),
1.50 - [n.expr] + list(n.subs) + (expr and [expr] or [])
1.51 + compiler.ast.Getattr(n.expr, op),
1.52 + list(n.subs) + (expr and [expr] or [])
1.53 )
1.54
1.55 # Fix parse tree structure.
1.56
1.57 - if op == "delitem":
1.58 + if op == "__delitem__":
1.59 invocation = compiler.ast.Discard(invocation)
1.60
1.61 return self.process_structure_node(invocation)