# HG changeset patch # User Paul Boddie # Date 1337278973 -7200 # Node ID 160410d522daa9b7a309896378f0a95ab6d1e0c4 # Parent 78a04625ecca7c9a0e22fe0e1ebe7cddc5fa1e10 Added *args to the visit method signatures and invocations. Added a default visit method that invokes the visitor's default method. diff -r 78a04625ecca -r 160410d522da compiler/ast.py --- a/compiler/ast.py Wed May 16 00:45:58 2012 +0200 +++ b/compiler/ast.py Thu May 17 20:22:53 2012 +0200 @@ -31,6 +31,8 @@ return self.getChildren() def getChildNodes(self): pass # implemented by subclasses + def visit(self, visitor, *args): + visitor.default(self, *args) class EmptyNode(Node): pass @@ -50,8 +52,8 @@ def __repr__(self): return "Expression(%s)" % (repr(self.node)) - def visit(self, visitor): - return visitor.visitExpression(self) + def visit(self, visitor, *args): + return visitor.visitExpression(self, *args) class Add(Node): def __init__(self, (left, right), lineno=None): @@ -68,8 +70,8 @@ def __repr__(self): return "Add((%s, %s))" % (repr(self.left), repr(self.right)) - def visit(self, visitor): - return visitor.visitAdd(self) + def visit(self, visitor, *args): + return visitor.visitAdd(self, *args) class And(Node): def __init__(self, nodes, lineno=None): @@ -87,8 +89,8 @@ def __repr__(self): return "And(%s)" % (repr(self.nodes),) - def visit(self, visitor): - return visitor.visitAnd(self) + def visit(self, visitor, *args): + return visitor.visitAnd(self, *args) class AssAttr(Node): def __init__(self, expr, attrname, flags, lineno=None): @@ -106,8 +108,8 @@ def __repr__(self): return "AssAttr(%s, %s, %s)" % (repr(self.expr), repr(self.attrname), repr(self.flags)) - def visit(self, visitor): - return visitor.visitAssAttr(self) + def visit(self, visitor, *args): + return visitor.visitAssAttr(self, *args) class AssList(Node): def __init__(self, nodes, lineno=None): @@ -125,8 +127,8 @@ def __repr__(self): return "AssList(%s)" % (repr(self.nodes),) - def visit(self, visitor): - return visitor.visitAssList(self) + def visit(self, visitor, *args): + return visitor.visitAssList(self, *args) class AssName(Node): def __init__(self, name, flags, lineno=None): @@ -143,8 +145,8 @@ def __repr__(self): return "AssName(%s, %s)" % (repr(self.name), repr(self.flags)) - def visit(self, visitor): - return visitor.visitAssName(self) + def visit(self, visitor, *args): + return visitor.visitAssName(self, *args) class AssTuple(Node): def __init__(self, nodes, lineno=None): @@ -162,8 +164,8 @@ def __repr__(self): return "AssTuple(%s)" % (repr(self.nodes),) - def visit(self, visitor): - return visitor.visitAssTuple(self) + def visit(self, visitor, *args): + return visitor.visitAssTuple(self, *args) class Assert(Node): def __init__(self, test, fail, lineno=None): @@ -187,8 +189,8 @@ def __repr__(self): return "Assert(%s, %s)" % (repr(self.test), repr(self.fail)) - def visit(self, visitor): - return visitor.visitAssert(self) + def visit(self, visitor, *args): + return visitor.visitAssert(self, *args) class Assign(Node): def __init__(self, nodes, expr, lineno=None): @@ -211,8 +213,8 @@ def __repr__(self): return "Assign(%s, %s)" % (repr(self.nodes), repr(self.expr)) - def visit(self, visitor): - return visitor.visitAssign(self) + def visit(self, visitor, *args): + return visitor.visitAssign(self, *args) class AugAssign(Node): def __init__(self, node, op, expr, lineno=None): @@ -230,8 +232,8 @@ def __repr__(self): return "AugAssign(%s, %s, %s)" % (repr(self.node), repr(self.op), repr(self.expr)) - def visit(self, visitor): - return visitor.visitAugAssign(self) + def visit(self, visitor, *args): + return visitor.visitAugAssign(self, *args) class Backquote(Node): def __init__(self, expr, lineno=None): @@ -247,8 +249,8 @@ def __repr__(self): return "Backquote(%s)" % (repr(self.expr),) - def visit(self, visitor): - return visitor.visitBackquote(self) + def visit(self, visitor, *args): + return visitor.visitBackquote(self, *args) class Bitand(Node): def __init__(self, nodes, lineno=None): @@ -266,8 +268,8 @@ def __repr__(self): return "Bitand(%s)" % (repr(self.nodes),) - def visit(self, visitor): - return visitor.visitBitand(self) + def visit(self, visitor, *args): + return visitor.visitBitand(self, *args) class Bitor(Node): def __init__(self, nodes, lineno=None): @@ -285,8 +287,8 @@ def __repr__(self): return "Bitor(%s)" % (repr(self.nodes),) - def visit(self, visitor): - return visitor.visitBitor(self) + def visit(self, visitor, *args): + return visitor.visitBitor(self, *args) class Bitxor(Node): def __init__(self, nodes, lineno=None): @@ -304,8 +306,8 @@ def __repr__(self): return "Bitxor(%s)" % (repr(self.nodes),) - def visit(self, visitor): - return visitor.visitBitxor(self) + def visit(self, visitor, *args): + return visitor.visitBitxor(self, *args) class Break(Node): def __init__(self, lineno=None): @@ -320,8 +322,8 @@ def __repr__(self): return "Break()" - def visit(self, visitor): - return visitor.visitBreak(self) + def visit(self, visitor, *args): + return visitor.visitBreak(self, *args) class CallFunc(Node): def __init__(self, node, args, star_args = None, dstar_args = None, lineno=None): @@ -352,8 +354,8 @@ def __repr__(self): return "CallFunc(%s, %s, %s, %s)" % (repr(self.node), repr(self.args), repr(self.star_args), repr(self.dstar_args)) - def visit(self, visitor): - return visitor.visitCallFunc(self) + def visit(self, visitor, *args): + return visitor.visitCallFunc(self, *args) class Class(Node): def __init__(self, name, bases, doc, code, lineno=None): @@ -380,8 +382,8 @@ def __repr__(self): return "Class(%s, %s, %s, %s)" % (repr(self.name), repr(self.bases), repr(self.doc), repr(self.code)) - def visit(self, visitor): - return visitor.visitClass(self) + def visit(self, visitor, *args): + return visitor.visitClass(self, *args) class Compare(Node): def __init__(self, expr, ops, lineno=None): @@ -404,8 +406,8 @@ def __repr__(self): return "Compare(%s, %s)" % (repr(self.expr), repr(self.ops)) - def visit(self, visitor): - return visitor.visitCompare(self) + def visit(self, visitor, *args): + return visitor.visitCompare(self, *args) class Const(Node): def __init__(self, value, lineno=None): @@ -421,8 +423,8 @@ def __repr__(self): return "Const(%s)" % (repr(self.value),) - def visit(self, visitor): - return visitor.visitConst(self) + def visit(self, visitor, *args): + return visitor.visitConst(self, *args) class Continue(Node): def __init__(self, lineno=None): @@ -437,8 +439,8 @@ def __repr__(self): return "Continue()" - def visit(self, visitor): - return visitor.visitContinue(self) + def visit(self, visitor, *args): + return visitor.visitContinue(self, *args) class Decorators(Node): def __init__(self, nodes, lineno=None): @@ -456,8 +458,8 @@ def __repr__(self): return "Decorators(%s)" % (repr(self.nodes),) - def visit(self, visitor): - return visitor.visitDecorators(self) + def visit(self, visitor, *args): + return visitor.visitDecorators(self, *args) class Dict(Node): def __init__(self, items, lineno=None): @@ -475,8 +477,8 @@ def __repr__(self): return "Dict(%s)" % (repr(self.items),) - def visit(self, visitor): - return visitor.visitDict(self) + def visit(self, visitor, *args): + return visitor.visitDict(self, *args) class Discard(Node): def __init__(self, expr, lineno=None): @@ -492,8 +494,8 @@ def __repr__(self): return "Discard(%s)" % (repr(self.expr),) - def visit(self, visitor): - return visitor.visitDiscard(self) + def visit(self, visitor, *args): + return visitor.visitDiscard(self, *args) class Div(Node): def __init__(self, (left, right), lineno=None): @@ -510,8 +512,8 @@ def __repr__(self): return "Div((%s, %s))" % (repr(self.left), repr(self.right)) - def visit(self, visitor): - return visitor.visitDiv(self) + def visit(self, visitor, *args): + return visitor.visitDiv(self, *args) class Ellipsis(Node): def __init__(self, lineno=None): @@ -526,8 +528,8 @@ def __repr__(self): return "Ellipsis()" - def visit(self, visitor): - return visitor.visitEllipsis(self) + def visit(self, visitor, *args): + return visitor.visitEllipsis(self, *args) class Exec(Node): def __init__(self, expr, locals, globals, lineno=None): @@ -555,8 +557,8 @@ def __repr__(self): return "Exec(%s, %s, %s)" % (repr(self.expr), repr(self.locals), repr(self.globals)) - def visit(self, visitor): - return visitor.visitExec(self) + def visit(self, visitor, *args): + return visitor.visitExec(self, *args) class FloorDiv(Node): def __init__(self, (left, right), lineno=None): @@ -573,8 +575,8 @@ def __repr__(self): return "FloorDiv((%s, %s))" % (repr(self.left), repr(self.right)) - def visit(self, visitor): - return visitor.visitFloorDiv(self) + def visit(self, visitor, *args): + return visitor.visitFloorDiv(self, *args) class For(Node): def __init__(self, assign, list, body, else_, lineno=None): @@ -604,8 +606,8 @@ def __repr__(self): return "For(%s, %s, %s, %s)" % (repr(self.assign), repr(self.list), repr(self.body), repr(self.else_)) - def visit(self, visitor): - return visitor.visitFor(self) + def visit(self, visitor, *args): + return visitor.visitFor(self, *args) class From(Node): def __init__(self, modname, names, level, lineno=None): @@ -623,8 +625,8 @@ def __repr__(self): return "From(%s, %s, %s)" % (repr(self.modname), repr(self.names), repr(self.level)) - def visit(self, visitor): - return visitor.visitFrom(self) + def visit(self, visitor, *args): + return visitor.visitFrom(self, *args) class Function(Node): def __init__(self, decorators, name, argnames, defaults, flags, doc, code, lineno=None): @@ -666,8 +668,8 @@ def __repr__(self): return "Function(%s, %s, %s, %s, %s, %s, %s)" % (repr(self.decorators), repr(self.name), repr(self.argnames), repr(self.defaults), repr(self.flags), repr(self.doc), repr(self.code)) - def visit(self, visitor): - return visitor.visitFunction(self) + def visit(self, visitor, *args): + return visitor.visitFunction(self, *args) class GenExpr(Node): def __init__(self, code, lineno=None): @@ -685,8 +687,8 @@ def __repr__(self): return "GenExpr(%s)" % (repr(self.code),) - def visit(self, visitor): - return visitor.visitGenExpr(self) + def visit(self, visitor, *args): + return visitor.visitGenExpr(self, *args) class GenExprFor(Node): def __init__(self, assign, iter, ifs, lineno=None): @@ -714,8 +716,8 @@ def __repr__(self): return "GenExprFor(%s, %s, %s)" % (repr(self.assign), repr(self.iter), repr(self.ifs)) - def visit(self, visitor): - return visitor.visitGenExprFor(self) + def visit(self, visitor, *args): + return visitor.visitGenExprFor(self, *args) class GenExprIf(Node): def __init__(self, test, lineno=None): @@ -731,8 +733,8 @@ def __repr__(self): return "GenExprIf(%s)" % (repr(self.test),) - def visit(self, visitor): - return visitor.visitGenExprIf(self) + def visit(self, visitor, *args): + return visitor.visitGenExprIf(self, *args) class GenExprInner(Node): def __init__(self, expr, quals, lineno=None): @@ -755,8 +757,8 @@ def __repr__(self): return "GenExprInner(%s, %s)" % (repr(self.expr), repr(self.quals)) - def visit(self, visitor): - return visitor.visitGenExprInner(self) + def visit(self, visitor, *args): + return visitor.visitGenExprInner(self, *args) class Getattr(Node): def __init__(self, expr, attrname, lineno=None): @@ -773,8 +775,8 @@ def __repr__(self): return "Getattr(%s, %s)" % (repr(self.expr), repr(self.attrname)) - def visit(self, visitor): - return visitor.visitGetattr(self) + def visit(self, visitor, *args): + return visitor.visitGetattr(self, *args) class Global(Node): def __init__(self, names, lineno=None): @@ -790,8 +792,8 @@ def __repr__(self): return "Global(%s)" % (repr(self.names),) - def visit(self, visitor): - return visitor.visitGlobal(self) + def visit(self, visitor, *args): + return visitor.visitGlobal(self, *args) class If(Node): def __init__(self, tests, else_, lineno=None): @@ -815,8 +817,8 @@ def __repr__(self): return "If(%s, %s)" % (repr(self.tests), repr(self.else_)) - def visit(self, visitor): - return visitor.visitIf(self) + def visit(self, visitor, *args): + return visitor.visitIf(self, *args) class IfExp(Node): def __init__(self, test, then, else_, lineno=None): @@ -834,8 +836,8 @@ def __repr__(self): return "IfExp(%s, %s, %s)" % (repr(self.test), repr(self.then), repr(self.else_)) - def visit(self, visitor): - return visitor.visitIfExp(self) + def visit(self, visitor, *args): + return visitor.visitIfExp(self, *args) class Import(Node): def __init__(self, names, lineno=None): @@ -851,8 +853,8 @@ def __repr__(self): return "Import(%s)" % (repr(self.names),) - def visit(self, visitor): - return visitor.visitImport(self) + def visit(self, visitor, *args): + return visitor.visitImport(self, *args) class Invert(Node): def __init__(self, expr, lineno=None): @@ -868,8 +870,8 @@ def __repr__(self): return "Invert(%s)" % (repr(self.expr),) - def visit(self, visitor): - return visitor.visitInvert(self) + def visit(self, visitor, *args): + return visitor.visitInvert(self, *args) class Keyword(Node): def __init__(self, name, expr, lineno=None): @@ -886,8 +888,8 @@ def __repr__(self): return "Keyword(%s, %s)" % (repr(self.name), repr(self.expr)) - def visit(self, visitor): - return visitor.visitKeyword(self) + def visit(self, visitor, *args): + return visitor.visitKeyword(self, *args) class Lambda(Node): def __init__(self, argnames, defaults, flags, code, lineno=None): @@ -921,8 +923,8 @@ def __repr__(self): return "Lambda(%s, %s, %s, %s)" % (repr(self.argnames), repr(self.defaults), repr(self.flags), repr(self.code)) - def visit(self, visitor): - return visitor.visitLambda(self) + def visit(self, visitor, *args): + return visitor.visitLambda(self, *args) class LeftShift(Node): def __init__(self, (left, right), lineno=None): @@ -939,8 +941,8 @@ def __repr__(self): return "LeftShift((%s, %s))" % (repr(self.left), repr(self.right)) - def visit(self, visitor): - return visitor.visitLeftShift(self) + def visit(self, visitor, *args): + return visitor.visitLeftShift(self, *args) class List(Node): def __init__(self, nodes, lineno=None): @@ -958,8 +960,8 @@ def __repr__(self): return "List(%s)" % (repr(self.nodes),) - def visit(self, visitor): - return visitor.visitList(self) + def visit(self, visitor, *args): + return visitor.visitList(self, *args) class ListComp(Node): def __init__(self, expr, quals, lineno=None): @@ -982,8 +984,8 @@ def __repr__(self): return "ListComp(%s, %s)" % (repr(self.expr), repr(self.quals)) - def visit(self, visitor): - return visitor.visitListComp(self) + def visit(self, visitor, *args): + return visitor.visitListComp(self, *args) class ListCompFor(Node): def __init__(self, assign, list, ifs, lineno=None): @@ -1009,8 +1011,8 @@ def __repr__(self): return "ListCompFor(%s, %s, %s)" % (repr(self.assign), repr(self.list), repr(self.ifs)) - def visit(self, visitor): - return visitor.visitListCompFor(self) + def visit(self, visitor, *args): + return visitor.visitListCompFor(self, *args) class ListCompIf(Node): def __init__(self, test, lineno=None): @@ -1026,8 +1028,8 @@ def __repr__(self): return "ListCompIf(%s)" % (repr(self.test),) - def visit(self, visitor): - return visitor.visitListCompIf(self) + def visit(self, visitor, *args): + return visitor.visitListCompIf(self, *args) class Mod(Node): def __init__(self, (left, right), lineno=None): @@ -1044,8 +1046,8 @@ def __repr__(self): return "Mod((%s, %s))" % (repr(self.left), repr(self.right)) - def visit(self, visitor): - return visitor.visitMod(self) + def visit(self, visitor, *args): + return visitor.visitMod(self, *args) class Module(Node): def __init__(self, doc, node, lineno=None): @@ -1062,8 +1064,8 @@ def __repr__(self): return "Module(%s, %s)" % (repr(self.doc), repr(self.node)) - def visit(self, visitor): - return visitor.visitModule(self) + def visit(self, visitor, *args): + return visitor.visitModule(self, *args) class Mul(Node): def __init__(self, (left, right), lineno=None): @@ -1080,8 +1082,8 @@ def __repr__(self): return "Mul((%s, %s))" % (repr(self.left), repr(self.right)) - def visit(self, visitor): - return visitor.visitMul(self) + def visit(self, visitor, *args): + return visitor.visitMul(self, *args) class Name(Node): def __init__(self, name, lineno=None): @@ -1097,8 +1099,8 @@ def __repr__(self): return "Name(%s)" % (repr(self.name),) - def visit(self, visitor): - return visitor.visitName(self) + def visit(self, visitor, *args): + return visitor.visitName(self, *args) class Not(Node): def __init__(self, expr, lineno=None): @@ -1114,8 +1116,8 @@ def __repr__(self): return "Not(%s)" % (repr(self.expr),) - def visit(self, visitor): - return visitor.visitNot(self) + def visit(self, visitor, *args): + return visitor.visitNot(self, *args) class Or(Node): def __init__(self, nodes, lineno=None): @@ -1133,8 +1135,8 @@ def __repr__(self): return "Or(%s)" % (repr(self.nodes),) - def visit(self, visitor): - return visitor.visitOr(self) + def visit(self, visitor, *args): + return visitor.visitOr(self, *args) class Pass(Node): def __init__(self, lineno=None): @@ -1149,8 +1151,8 @@ def __repr__(self): return "Pass()" - def visit(self, visitor): - return visitor.visitPass(self) + def visit(self, visitor, *args): + return visitor.visitPass(self, *args) class Power(Node): def __init__(self, (left, right), lineno=None): @@ -1167,8 +1169,8 @@ def __repr__(self): return "Power((%s, %s))" % (repr(self.left), repr(self.right)) - def visit(self, visitor): - return visitor.visitPower(self) + def visit(self, visitor, *args): + return visitor.visitPower(self, *args) class Print(Node): def __init__(self, nodes, dest, lineno=None): @@ -1192,8 +1194,8 @@ def __repr__(self): return "Print(%s, %s)" % (repr(self.nodes), repr(self.dest)) - def visit(self, visitor): - return visitor.visitPrint(self) + def visit(self, visitor, *args): + return visitor.visitPrint(self, *args) class Printnl(Node): def __init__(self, nodes, dest, lineno=None): @@ -1217,8 +1219,8 @@ def __repr__(self): return "Printnl(%s, %s)" % (repr(self.nodes), repr(self.dest)) - def visit(self, visitor): - return visitor.visitPrintnl(self) + def visit(self, visitor, *args): + return visitor.visitPrintnl(self, *args) class Raise(Node): def __init__(self, expr1, expr2, expr3, lineno=None): @@ -1247,8 +1249,8 @@ def __repr__(self): return "Raise(%s, %s, %s)" % (repr(self.expr1), repr(self.expr2), repr(self.expr3)) - def visit(self, visitor): - return visitor.visitRaise(self) + def visit(self, visitor, *args): + return visitor.visitRaise(self, *args) class Return(Node): def __init__(self, value, lineno=None): @@ -1264,8 +1266,8 @@ def __repr__(self): return "Return(%s)" % (repr(self.value),) - def visit(self, visitor): - return visitor.visitReturn(self) + def visit(self, visitor, *args): + return visitor.visitReturn(self, *args) class RightShift(Node): def __init__(self, (left, right), lineno=None): @@ -1282,8 +1284,8 @@ def __repr__(self): return "RightShift((%s, %s))" % (repr(self.left), repr(self.right)) - def visit(self, visitor): - return visitor.visitRightShift(self) + def visit(self, visitor, *args): + return visitor.visitRightShift(self, *args) class Slice(Node): def __init__(self, expr, flags, lower, upper, lineno=None): @@ -1313,8 +1315,8 @@ def __repr__(self): return "Slice(%s, %s, %s, %s)" % (repr(self.expr), repr(self.flags), repr(self.lower), repr(self.upper)) - def visit(self, visitor): - return visitor.visitSlice(self) + def visit(self, visitor, *args): + return visitor.visitSlice(self, *args) class Sliceobj(Node): def __init__(self, nodes, lineno=None): @@ -1332,8 +1334,8 @@ def __repr__(self): return "Sliceobj(%s)" % (repr(self.nodes),) - def visit(self, visitor): - return visitor.visitSliceobj(self) + def visit(self, visitor, *args): + return visitor.visitSliceobj(self, *args) class Stmt(Node): def __init__(self, nodes, lineno=None): @@ -1351,8 +1353,8 @@ def __repr__(self): return "Stmt(%s)" % (repr(self.nodes),) - def visit(self, visitor): - return visitor.visitStmt(self) + def visit(self, visitor, *args): + return visitor.visitStmt(self, *args) class Sub(Node): def __init__(self, (left, right), lineno=None): @@ -1369,8 +1371,8 @@ def __repr__(self): return "Sub((%s, %s))" % (repr(self.left), repr(self.right)) - def visit(self, visitor): - return visitor.visitSub(self) + def visit(self, visitor, *args): + return visitor.visitSub(self, *args) class Subscript(Node): def __init__(self, expr, flags, subs, lineno=None): @@ -1395,8 +1397,8 @@ def __repr__(self): return "Subscript(%s, %s, %s)" % (repr(self.expr), repr(self.flags), repr(self.subs)) - def visit(self, visitor): - return visitor.visitSubscript(self) + def visit(self, visitor, *args): + return visitor.visitSubscript(self, *args) class TryExcept(Node): def __init__(self, body, handlers, else_, lineno=None): @@ -1423,8 +1425,8 @@ def __repr__(self): return "TryExcept(%s, %s, %s)" % (repr(self.body), repr(self.handlers), repr(self.else_)) - def visit(self, visitor): - return visitor.visitTryExcept(self) + def visit(self, visitor, *args): + return visitor.visitTryExcept(self, *args) class TryFinally(Node): def __init__(self, body, final, lineno=None): @@ -1441,8 +1443,8 @@ def __repr__(self): return "TryFinally(%s, %s)" % (repr(self.body), repr(self.final)) - def visit(self, visitor): - return visitor.visitTryFinally(self) + def visit(self, visitor, *args): + return visitor.visitTryFinally(self, *args) class Tuple(Node): def __init__(self, nodes, lineno=None): @@ -1460,8 +1462,8 @@ def __repr__(self): return "Tuple(%s)" % (repr(self.nodes),) - def visit(self, visitor): - return visitor.visitTuple(self) + def visit(self, visitor, *args): + return visitor.visitTuple(self, *args) class UnaryAdd(Node): def __init__(self, expr, lineno=None): @@ -1477,8 +1479,8 @@ def __repr__(self): return "UnaryAdd(%s)" % (repr(self.expr),) - def visit(self, visitor): - return visitor.visitUnaryAdd(self) + def visit(self, visitor, *args): + return visitor.visitUnaryAdd(self, *args) class UnarySub(Node): def __init__(self, expr, lineno=None): @@ -1494,8 +1496,8 @@ def __repr__(self): return "UnarySub(%s)" % (repr(self.expr),) - def visit(self, visitor): - return visitor.visitUnarySub(self) + def visit(self, visitor, *args): + return visitor.visitUnarySub(self, *args) class While(Node): def __init__(self, test, body, else_, lineno=None): @@ -1522,8 +1524,8 @@ def __repr__(self): return "While(%s, %s, %s)" % (repr(self.test), repr(self.body), repr(self.else_)) - def visit(self, visitor): - return visitor.visitWhile(self) + def visit(self, visitor, *args): + return visitor.visitWhile(self, *args) class With(Node): def __init__(self, expr, vars, body, lineno=None): @@ -1550,8 +1552,8 @@ def __repr__(self): return "With(%s, %s, %s)" % (repr(self.expr), repr(self.vars), repr(self.body)) - def visit(self, visitor): - return visitor.visitWith(self) + def visit(self, visitor, *args): + return visitor.visitWith(self, *args) class Yield(Node): def __init__(self, value, lineno=None): @@ -1567,8 +1569,8 @@ def __repr__(self): return "Yield(%s)" % (repr(self.value),) - def visit(self, visitor): - return visitor.visitYield(self) + def visit(self, visitor, *args): + return visitor.visitYield(self, *args) for name, obj in globals().items(): if isinstance(obj, type) and issubclass(obj, Node):