# HG changeset patch # User Paul Boddie # Date 1337278973 -7200 # Node ID c5f8bc4e9eee909f6f4bb520efc4e9def3033839 # Parent 2b976fdcb84aa021850da3cb9c0ef5af5895bcf2 Added *args to the visit method signatures and invocations. Added a default visit method that invokes the visitor's default method. diff -r 2b976fdcb84a -r c5f8bc4e9eee compiler/ast.py --- a/compiler/ast.py Fri May 18 23:44:12 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, leftright, 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, decorators = None, lineno=None): @@ -384,8 +386,8 @@ def __repr__(self): return "Class(%s, %s, %s, %s, %s)" % (repr(self.name), repr(self.bases), repr(self.doc), repr(self.code), repr(self.decorators)) - 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): @@ -408,8 +410,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): @@ -425,8 +427,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): @@ -441,8 +443,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): @@ -460,8 +462,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): @@ -479,8 +481,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): @@ -496,8 +498,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, leftright, lineno=None): @@ -514,8 +516,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): @@ -530,8 +532,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): @@ -559,8 +561,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, leftright, lineno=None): @@ -577,8 +579,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): @@ -608,8 +610,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): @@ -627,8 +629,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): @@ -669,8 +671,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): @@ -689,8 +691,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): @@ -717,8 +719,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): @@ -734,8 +736,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): @@ -758,8 +760,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): @@ -776,8 +778,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): @@ -793,8 +795,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): @@ -818,8 +820,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): @@ -837,8 +839,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): @@ -854,8 +856,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): @@ -871,8 +873,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): @@ -889,8 +891,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): @@ -923,8 +925,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, leftright, lineno=None): @@ -941,8 +943,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): @@ -960,8 +962,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): @@ -984,8 +986,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): @@ -1011,8 +1013,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): @@ -1028,8 +1030,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, leftright, lineno=None): @@ -1046,8 +1048,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): @@ -1064,8 +1066,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, leftright, lineno=None): @@ -1082,8 +1084,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): @@ -1099,8 +1101,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): @@ -1116,8 +1118,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): @@ -1135,8 +1137,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): @@ -1151,8 +1153,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, leftright, lineno=None): @@ -1169,8 +1171,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): @@ -1194,8 +1196,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): @@ -1219,8 +1221,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): @@ -1249,8 +1251,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): @@ -1266,8 +1268,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, leftright, lineno=None): @@ -1284,8 +1286,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): @@ -1315,8 +1317,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): @@ -1334,8 +1336,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): @@ -1353,8 +1355,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, leftright, lineno=None): @@ -1371,8 +1373,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): @@ -1397,8 +1399,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): @@ -1425,8 +1427,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): @@ -1443,8 +1445,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): @@ -1462,8 +1464,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): @@ -1479,8 +1481,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): @@ -1496,8 +1498,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): @@ -1524,8 +1526,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): @@ -1552,8 +1554,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): @@ -1569,8 +1571,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):