# HG changeset patch # User paulb@localhost.localdomain # Date 1165022447 -3600 # Node ID 26af16cddaa26054aa5ae39ea7277ed9f71ae1db # Parent 618ca8ff9c3e5c806c8697a3b3cc1b60976aa686 Added Power. Removed some redundant lines. Added some viewer error resistance. diff -r 618ca8ff9c3e -r 26af16cddaa2 annotate.py --- a/annotate.py Sat Dec 02 01:28:16 2006 +0100 +++ b/annotate.py Sat Dec 02 02:20:47 2006 +0100 @@ -652,11 +652,6 @@ else: instance = type.instances[0] - #instance = Instance() - #instance.namespace = Namespace() - #instance.namespace.store("__class__", [Attribute(None, type)]) - #type.instances.append(instance) - node.instances[(reason, target, type)] = instance return node.instances[(reason, target, type)] diff -r 618ca8ff9c3e -r 26af16cddaa2 simplify.py --- a/simplify.py Sat Dec 02 01:28:16 2006 +0100 +++ b/simplify.py Sat Dec 02 02:20:47 2006 +0100 @@ -51,12 +51,12 @@ Break, CallFunc, Class, Compare, Const, Continue, Dict, Discard, Div, FloorDiv, For, From, Function, Getattr, Global, If, Import, Invert, Keyword, Lambda, List, Module, Mul, Name, Not, Or, Pass, - Raise, Return, Slice, Stmt, Sub, Subscript, TryExcept, TryFinally, - Tuple, While, UnaryAdd, UnarySub. + Power, Raise, Return, Slice, Stmt, Sub, Subscript, TryExcept, + TryFinally, Tuple, While, UnaryAdd, UnarySub. Missing: Assert, Backquote, Bitand, Bitor, Bitxor, Decorators, Ellipsis, - Exec, LeftShift, ListComp, ListCompFor, ListCompIf, - Power, Print, Printnl, RightShift, Sliceobj, Yield. + Exec, LeftShift, ListComp, ListCompFor, ListCompIf, Print, Printnl, + RightShift, Sliceobj, Yield. """ def __init__(self, builtins=0): @@ -999,6 +999,9 @@ def visitPass(self, pass_): return Pass(pass_, 1) + def visitPower(self, power): + return self._visitBinary(power, "__pow__", "__rpow__") + def visitRaise(self, raise_): result = Raise(raise_, 1) if raise_.expr2 is None: diff -r 618ca8ff9c3e -r 26af16cddaa2 viewer.py --- a/viewer.py Sat Dec 02 01:28:16 2006 +0100 +++ b/viewer.py Sat Dec 02 02:20:47 2006 +0100 @@ -88,9 +88,10 @@ self.stream.write("Nodes:\n\n") for node in exc.nodes: self.stream.write(repr(node) + "\n") - if node is not None: + if node is not None and hasattr(node, "original"): self.dispatch_only(node.original, every_time=1) - self.stream.write("\nOriginal node was:\n\n" + repr(exc.nodes[0].original) + "\n") + if hasattr(exc.nodes[0], "original"): + self.stream.write("\nOriginal node was:\n\n" + repr(exc.nodes[0].original) + "\n") self.stream.write("\nSimplified node was:\n\n") exc.nodes[0].pprint(stream=self.stream) @@ -689,6 +690,9 @@ first = 0 self.stream.write("") + def visitPower(self, node): + self._visitBinary(node, "power", "**") + def visitSlice(self, node): self.stream.write("\n") self.dispatch(node.expr)