simplify

Changeset

36:5795b85355ef
2006-08-01 paulb raw files shortlog changelog graph Fixed handler attribute visiting in fixnames, along with some incorrectly defined code attributes.
fixnames.py (file) simplify.py (file)
     1.1 --- a/fixnames.py	Mon Jul 31 21:20:33 2006 +0200
     1.2 +++ b/fixnames.py	Tue Aug 01 00:56:22 2006 +0200
     1.3 @@ -94,11 +94,11 @@
     1.4              value = getattr(node, attr, None)
     1.5              if value is not None:
     1.6                  setattr(node, attr, self.dispatches(value))
     1.7 -        for attr in ("expr", "lvalue", "test", "handler", "star", "dstar"):
     1.8 +        for attr in ("expr", "lvalue", "test", "star", "dstar"):
     1.9              value = getattr(node, attr, None)
    1.10              if value is not None:
    1.11                  setattr(node, attr, self.dispatch(value))
    1.12 -        for attr in ("body", "else_", "finally_", "code", "choices"):
    1.13 +        for attr in ("body", "else_", "handler", "finally_", "code", "choices"):
    1.14              value = getattr(node, attr, None)
    1.15              if value is not None:
    1.16                  setattr(node, attr, self.dispatches(value))
     2.1 --- a/simplify.py	Mon Jul 31 21:20:33 2006 +0200
     2.2 +++ b/simplify.py	Tue Aug 01 00:56:22 2006 +0200
     2.3 @@ -831,7 +831,7 @@
     2.4  
     2.5          # Finish the subprogram definition.
     2.6  
     2.7 -        subprogram.code = test
     2.8 +        subprogram.code = [test]
     2.9  
    2.10          self.current_subprograms.pop()
    2.11          self.subprograms.append(subprogram)
    2.12 @@ -875,13 +875,14 @@
    2.13          # Wrap the assignment in a try...except statement.
    2.14  
    2.15          try_except = Try(body=[], else_=[], finally_=[])
    2.16 -        try_except.handler = Conditional(
    2.17 +        test = Conditional(
    2.18              test=Invoke(
    2.19                  expr=LoadName(name="isinstance"),
    2.20                  args=[LoadExc(), LoadName(name="StopIteration")], star=None, dstar=None
    2.21                  ),
    2.22              body=else_stmt,
    2.23              else_=[Raise(expr=LoadExc())])
    2.24 +        try_except.handler = [test]
    2.25  
    2.26          assign = Assign()
    2.27          assign.code = [