PEP 342 implementation. Per Guido's comments, the generator throw()

method still needs to support string exceptions, and allow None for the
third argument.  Documentation updates are needed, too.
This commit is contained in:
Phillip J. Eby 2005-08-02 00:46:46 +00:00
parent d794666048
commit 0d6615fd29
16 changed files with 862 additions and 242 deletions

View file

@ -403,7 +403,15 @@ class Transformer:
return Return(self.com_node(nodelist[1]), lineno=nodelist[0][2])
def yield_stmt(self, nodelist):
return Yield(self.com_node(nodelist[1]), lineno=nodelist[0][2])
expr = self.com_node(nodelist[0])
return Discard(expr, lineno=expr.lineno)
def yield_expr(self, nodelist):
if len(nodelist)>1:
value = nodelist[1]
else:
value = Const(None)
return Yield(self.com_node(value), lineno=nodelist[0][2])
def raise_stmt(self, nodelist):
# raise: [test [',' test [',' test]]]
@ -1402,6 +1410,8 @@ _legal_node_types = [
if hasattr(symbol, 'yield_stmt'):
_legal_node_types.append(symbol.yield_stmt)
if hasattr(symbol, 'yield_expr'):
_legal_node_types.append(symbol.yield_expr)
_assign_types = [
symbol.test,