tidy up tryexcept and tryfinally nodes

This commit is contained in:
Jeremy Hylton 2000-02-15 21:30:00 +00:00
parent 6e83cacb18
commit ca1ad182f2
2 changed files with 40 additions and 28 deletions

View File

@ -222,28 +222,34 @@ def __init__(self, expr1, expr2, expr3):
def __repr__(self): def __repr__(self):
return "Raise(%s,%s,%s)" % self._children[1:] return "Raise(%s,%s,%s)" % self._children[1:]
class Tryfinally(Node): class TryFinally(Node):
nodes['tryfinally'] = 'Tryfinally' nodes['tryfinally'] = 'TryFinally'
def __init__(self, try_, fin): def __init__(self, body, final):
self.try_ = try_ self.body = body
self.fin = fin self.final = final
self._children = ('tryfinally', try_, fin) self._children = ('tryfinally', body, final)
def __repr__(self): def __repr__(self):
return "Tryfinally(%s,%s)" % self._children[1:] return "TryFinally(%s,%s)" % self._children[1:]
class Tryexcept(Node): class TryExcept(Node):
nodes['tryexcept'] = 'Tryexcept' """Try/Except body and handlers
def __init__(self, try_, excs, else_): The handlers attribute is a sequence of tuples. The elements of the
self.try_ = try_ tuple are the exception name, the name to bind the exception to, and
self.excs = excs the body of the except clause.
"""
nodes['tryexcept'] = 'TryExcept'
def __init__(self, body, handlers, else_):
self.body = body
self.handlers = handlers
self.else_ = else_ self.else_ = else_
self._children = ('tryexcept', try_, excs, else_) self._children = ('tryexcept', body, handlers, else_)
def __repr__(self): def __repr__(self):
return "Tryexcept(%s,%s,%s)" % self._children[1:] return "TryExcept(%s,%s,%s)" % self._children[1:]
class Return(Node): class Return(Node):
nodes['return'] = 'Return' nodes['return'] = 'Return'

View File

@ -222,28 +222,34 @@ def __init__(self, expr1, expr2, expr3):
def __repr__(self): def __repr__(self):
return "Raise(%s,%s,%s)" % self._children[1:] return "Raise(%s,%s,%s)" % self._children[1:]
class Tryfinally(Node): class TryFinally(Node):
nodes['tryfinally'] = 'Tryfinally' nodes['tryfinally'] = 'TryFinally'
def __init__(self, try_, fin): def __init__(self, body, final):
self.try_ = try_ self.body = body
self.fin = fin self.final = final
self._children = ('tryfinally', try_, fin) self._children = ('tryfinally', body, final)
def __repr__(self): def __repr__(self):
return "Tryfinally(%s,%s)" % self._children[1:] return "TryFinally(%s,%s)" % self._children[1:]
class Tryexcept(Node): class TryExcept(Node):
nodes['tryexcept'] = 'Tryexcept' """Try/Except body and handlers
def __init__(self, try_, excs, else_): The handlers attribute is a sequence of tuples. The elements of the
self.try_ = try_ tuple are the exception name, the name to bind the exception to, and
self.excs = excs the body of the except clause.
"""
nodes['tryexcept'] = 'TryExcept'
def __init__(self, body, handlers, else_):
self.body = body
self.handlers = handlers
self.else_ = else_ self.else_ = else_
self._children = ('tryexcept', try_, excs, else_) self._children = ('tryexcept', body, handlers, else_)
def __repr__(self): def __repr__(self):
return "Tryexcept(%s,%s,%s)" % self._children[1:] return "TryExcept(%s,%s,%s)" % self._children[1:]
class Return(Node): class Return(Node):
nodes['return'] = 'Return' nodes['return'] = 'Return'