2.1 --- a/simplify.py Sat Dec 02 01:28:16 2006 +0100
2.2 +++ b/simplify.py Sat Dec 02 02:20:47 2006 +0100
2.3 @@ -51,12 +51,12 @@
2.4 Break, CallFunc, Class, Compare, Const, Continue, Dict, Discard,
2.5 Div, FloorDiv, For, From, Function, Getattr, Global, If, Import,
2.6 Invert, Keyword, Lambda, List, Module, Mul, Name, Not, Or, Pass,
2.7 - Raise, Return, Slice, Stmt, Sub, Subscript, TryExcept, TryFinally,
2.8 - Tuple, While, UnaryAdd, UnarySub.
2.9 + Power, Raise, Return, Slice, Stmt, Sub, Subscript, TryExcept,
2.10 + TryFinally, Tuple, While, UnaryAdd, UnarySub.
2.11
2.12 Missing: Assert, Backquote, Bitand, Bitor, Bitxor, Decorators, Ellipsis,
2.13 - Exec, LeftShift, ListComp, ListCompFor, ListCompIf,
2.14 - Power, Print, Printnl, RightShift, Sliceobj, Yield.
2.15 + Exec, LeftShift, ListComp, ListCompFor, ListCompIf, Print, Printnl,
2.16 + RightShift, Sliceobj, Yield.
2.17 """
2.18
2.19 def __init__(self, builtins=0):
2.20 @@ -999,6 +999,9 @@
2.21 def visitPass(self, pass_):
2.22 return Pass(pass_, 1)
2.23
2.24 + def visitPower(self, power):
2.25 + return self._visitBinary(power, "__pow__", "__rpow__")
2.26 +
2.27 def visitRaise(self, raise_):
2.28 result = Raise(raise_, 1)
2.29 if raise_.expr2 is None:
3.1 --- a/viewer.py Sat Dec 02 01:28:16 2006 +0100
3.2 +++ b/viewer.py Sat Dec 02 02:20:47 2006 +0100
3.3 @@ -88,9 +88,10 @@
3.4 self.stream.write("Nodes:\n\n")
3.5 for node in exc.nodes:
3.6 self.stream.write(repr(node) + "\n")
3.7 - if node is not None:
3.8 + if node is not None and hasattr(node, "original"):
3.9 self.dispatch_only(node.original, every_time=1)
3.10 - self.stream.write("\nOriginal node was:\n\n" + repr(exc.nodes[0].original) + "\n")
3.11 + if hasattr(exc.nodes[0], "original"):
3.12 + self.stream.write("\nOriginal node was:\n\n" + repr(exc.nodes[0].original) + "\n")
3.13 self.stream.write("\nSimplified node was:\n\n")
3.14 exc.nodes[0].pprint(stream=self.stream)
3.15
3.16 @@ -689,6 +690,9 @@
3.17 first = 0
3.18 self.stream.write("</span>")
3.19
3.20 + def visitPower(self, node):
3.21 + self._visitBinary(node, "power", "**")
3.22 +
3.23 def visitSlice(self, node):
3.24 self.stream.write("<span class='slice'>\n")
3.25 self.dispatch(node.expr)