1 #!/usr/bin/env python 2 3 """ 4 Simplify AST structures for easier type propagation and analysis. 5 6 Copyright (C) 2006 Paul Boddie <paul@boddie.org.uk> 7 8 This software is free software; you can redistribute it and/or 9 modify it under the terms of the GNU General Public License as 10 published by the Free Software Foundation; either version 2 of 11 the License, or (at your option) any later version. 12 13 This software is distributed in the hope that it will be useful, 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 GNU General Public License for more details. 17 18 You should have received a copy of the GNU General Public 19 License along with this library; see the file LICENCE.txt 20 If not, write to the Free Software Foundation, Inc., 21 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA 22 """ 23 24 from compiler.visitor import ASTVisitor 25 import compiler.ast 26 from simplified import * 27 28 class Simplifier(ASTVisitor): 29 30 """ 31 A simplifying visitor for AST nodes. 32 33 Covered: And, AssAttr, AssList, AssName, AssTuple, Assign, AugAssign, Break, 34 CallFunc, Class, Const, Continue, Dict, Discard, For, From, 35 Function, Getattr, Global, If, Import, Invert, Keyword, Lambda, 36 List, Module, Name, Not, Or, Pass, Raise, Return, Stmt, TryExcept, 37 TryFinally, Tuple, While, UnaryAdd, UnarySub. 38 39 Missing: Add, Assert, Backquote, Bitand, Bitor, Bitxor, Compare, Decorators, 40 Div, Ellipsis, Exec, FloorDiv, LeftShift, ListComp, ListCompFor, 41 ListCompIf, Mod, Mul, Power, Print, Printnl, RightShift, 42 Slice, Sliceobj, Sub, Subscript, Yield. 43 """ 44 45 def __init__(self): 46 ASTVisitor.__init__(self) 47 self.result = None # The resulting tree. 48 self.subprograms = [] # Subprograms outside the tree. 49 self.current_subprograms = [] # Current subprograms being processed. 50 51 # Generic visitor methods. 52 53 def default(self, node, *args): 54 raise ValueError, node.__class__ 55 56 def dispatch(self, node, *args): 57 return ASTVisitor.dispatch(self, node, *args) 58 59 def dispatches(self, nodes, *args): 60 results = [] 61 for node in nodes: 62 results.append(self.dispatch(node, *args)) 63 return results 64 65 def dispatch_or_none(self, node, *args): 66 if node is not None: 67 return self.dispatch(node, *args) 68 else: 69 return LoadName(name="None") 70 71 # Placeholder or deletion transformations. 72 73 def visitStmt(self, stmt): 74 return self.dispatches(stmt.nodes) 75 76 def visitPass(self, pass_): 77 return Pass(pass_) 78 79 def visitDiscard(self, discard): 80 return self.dispatch(discard.expr) 81 82 # Relatively trivial transformations. 83 84 def visitModule(self, module): 85 self.result = Module(module) 86 self.result.code = self.dispatch(module.node) 87 return self.result 88 89 def visitClass(self, class_): 90 result = Class(class_, name=class_.name, bases=class_.bases) 91 result.code = self.dispatch(class_.code) 92 return result 93 94 def visitGetattr(self, getattr): 95 result = LoadAttr(getattr, name=getattr.attrname) 96 result.expr = self.dispatch(getattr.expr) 97 return result 98 99 def visitKeyword(self, keyword): 100 result = Keyword(keyword, name=keyword.name) 101 result.expr = self.dispatch(keyword.expr) 102 return result 103 104 def visitGlobal(self, global_): 105 result = Global(global_, names=global_.names) 106 return result 107 108 def visitImport(self, import_): 109 result = Assign(import_) 110 code = [] 111 for path, alias in import_.names: 112 importer = Import(name=path) 113 top = alias or path.split(".")[0] 114 code.append(StoreName(expr=importer, name=top)) 115 result.code = code 116 return result 117 118 def visitFrom(self, from_): 119 result = Assign(from_) 120 code = [] 121 code.append(StoreTemp(expr=Import(name=from_.modname))) 122 for name, alias in from_.names: 123 code.append(StoreName(expr=LoadAttr(expr=LoadTemp(), name=name), name=(alias or name))) 124 result.code = code 125 return result 126 127 def visitName(self, name): 128 result = LoadName(name, name=name.name) 129 return result 130 131 def visitConst(self, const): 132 result = LoadConst(const, value=const.value) 133 return result 134 135 def visitReturn(self, return_): 136 result = Return(return_) 137 result.expr = self.dispatch(return_.value) 138 return result 139 140 def visitBreak(self, break_): 141 result = Return(break_) 142 return result 143 144 def visitContinue(self, continue_): 145 result = Invoke(continue_, same_frame=1, produces_result=0, star=None, dstar=None, args=[]) 146 result.expr = LoadRef(ref=self.current_subprograms[-1]) 147 return result 148 149 def visitRaise(self, raise_): 150 result = Raise(raise_, expr=self.dispatch(raise_.expr1), traceback=None) 151 if raise_.expr2 is not None: 152 result.args = [self.dispatch(raise_.expr2)] 153 if raise_.expr3 is not None: 154 result.traceback = self.dispatch(raise_.expr3) 155 return result 156 157 def visitIf(self, if_): 158 result = If(if_, else_=[]) 159 tests = [] 160 for compare, stmt in if_.tests: 161 # Produce something like... 162 # expr.__true__() ? body 163 test = Conditional(else_=[], test=Invoke( 164 expr=LoadAttr(expr=self.dispatch(compare), name="__true__"), 165 params=[], star=None, dstar=None)) 166 test.body = self.dispatch(stmt) 167 tests.append(test) 168 result.tests = tests 169 if if_.else_ is not None: 170 result.else_ = self.dispatch(if_.else_) 171 return result 172 173 def _visitBuiltin(self, builtin, name): 174 result = Invoke(builtin, expr=LoadName(name=name)) 175 result.args = self.dispatches(builtin.nodes) 176 return result 177 178 def visitTuple(self, tuple): 179 return self._visitBuiltin(tuple, "Tuple") 180 181 def visitList(self, list): 182 return self._visitBuiltin(list, "List") 183 184 def visitDict(self, dict): 185 result = Invoke(expr=LoadName(name="Dict")) 186 args = [] 187 for key, value in dict.items: 188 tuple = Invoke(expr=LoadName(name="Tuple"), star=None, dstar=None) 189 tuple.args = [self.dispatch(key), self.dispatch(value)] 190 args.append(tuple) 191 result.args = args 192 return result 193 194 # Logical operators. 195 196 def visitAnd(self, and_): 197 198 # Make a subprogram for the expression and record it outside the main tree. 199 200 subprogram = Subprogram(and_, name=hex(id(and_)), acquire_locals=1, returns_value=1, params=[], star=None, dstar=None) 201 self.current_subprograms.append(subprogram) 202 203 nodes = [] 204 last = and_.nodes[-1] 205 for node in and_.nodes: 206 expr = self.dispatch(node) 207 if node is not last: 208 invocation = Not(expr=Invoke(expr=LoadAttr(expr=StoreTemp(expr=expr), name="__true__"), 209 params=[], star=None, dstar=None)) 210 nodes.append(Conditional(test=invocation, body=[Return(expr=LoadTemp())])) 211 nodes.append(ReleaseTemp()) 212 else: 213 nodes.append(Return(expr=expr)) 214 subprogram.code = nodes 215 216 self.current_subprograms.pop() 217 self.subprograms.append(subprogram) 218 219 # Make an invocation of the subprogram. 220 221 result = Invoke(and_, same_frame=1, star=None, dstar=None, args=[]) 222 result.expr = LoadRef(ref=subprogram) 223 return result 224 225 def visitOr(self, or_): 226 227 # Make a subprogram for the expression and record it outside the main tree. 228 229 subprogram = Subprogram(or_, name=hex(id(or_)), acquire_locals=1, returns_value=1, params=[], star=None, dstar=None) 230 self.current_subprograms.append(subprogram) 231 232 nodes = [] 233 last = or_.nodes[-1] 234 for node in or_.nodes: 235 expr = self.dispatch(node) 236 if node is not last: 237 invocation = Invoke(expr=LoadAttr(expr=StoreTemp(expr=expr), name="__true__"), 238 params=[], star=None, dstar=None) 239 nodes.append(Conditional(test=invocation, body=[Return(expr=LoadTemp())])) 240 nodes.append(ReleaseTemp()) 241 else: 242 nodes.append(Return(expr=expr)) 243 subprogram.code = nodes 244 245 self.current_subprograms.pop() 246 self.subprograms.append(subprogram) 247 248 # Make an invocation of the subprogram. 249 250 result = Invoke(or_, same_frame=1, star=None, dstar=None, args=[]) 251 result.expr = LoadRef(ref=subprogram) 252 return result 253 254 def visitNot(self, not_): 255 result = Not(not_, expr=Invoke(expr=LoadAttr(expr=self.dispatch(not_.expr), name="__true__"), 256 params=[], star=None, dstar=None)) 257 return result 258 259 # Operators. 260 261 def visitUnaryAdd(self, unaryadd): 262 return Invoke(expr=LoadAttr(expr=self.dispatch(unaryadd.expr), name="__pos__"), args=[]) 263 264 def visitUnarySub(self, unarysub): 265 return Invoke(expr=LoadAttr(expr=self.dispatch(unarysub.expr), name="__neg__"), args=[]) 266 267 def visitInvert(self, invert): 268 return Invoke(expr=LoadAttr(expr=self.dispatch(invert.expr), name="__invert__"), args=[]) 269 270 # Assignments. 271 272 augassign_methods = { 273 "+=" : "__iadd__", "-=" : "__isub__", "*=" : "__imul__", "/=" : "__idiv__", 274 "%=" : "__imod__", "**=" : "__ipow__", "<<=" : "__ilshift__", ">>=" : "__irshift__", 275 "&=" : "__iand__", "^=" : "__ixor__", "|=" : "__ior__" 276 } 277 278 def visitAugAssign(self, augassign): 279 result = Assign(augassign) 280 expr = self.dispatch(augassign.expr) 281 282 # Simple augmented assignment: name += expr 283 284 if isinstance(augassign.node, compiler.ast.Name): 285 name = augassign.node 286 node = self.dispatch(name) 287 get_incremented = StoreTemp( 288 expr=Invoke(expr=LoadAttr(expr=node, name=self.augassign_methods[augassign.op]), args=[expr]) 289 ) 290 store = StoreName(expr=LoadTemp(), name=name.name) 291 result.code = [get_incremented, store, ReleaseTemp()] 292 293 # Complicated augmented assignment: lvalue.attr += expr 294 295 elif isinstance(augassign.node, compiler.ast.Getattr): 296 297 # <lvalue> -> setattr(<lvalue>, getattr(<lvalue>, "attr").__xxx__(expr)) 298 299 getattr = augassign.node 300 store_expr = StoreTemp(index="expr", expr=self.dispatch(getattr.expr)) 301 node_attr = LoadAttr(expr=LoadTemp(index="expr"), name=getattr.attrname) 302 get_incremented = StoreTemp( 303 expr=Invoke(expr=LoadAttr(expr=node_attr, name=self.augassign_methods[augassign.op]), args=[expr]) 304 ) 305 store = StoreAttr(expr=LoadTemp(), lvalue=LoadTemp(index="expr"), name=getattr.attrname) 306 result.code = [store_expr, get_incremented, store, ReleaseTemp(index="expr"), ReleaseTemp()] 307 308 # Complicated augassign using slices: lvalue[lower:upper] += expr 309 310 elif isinstance(augassign.node, compiler.ast.Slice): 311 312 # <lvalue>, <lower>, <upper> -> <lvalue>.__setslice__(<lower>, <upper>, <lvalue>.__getslice__(<lower>, <upper>).__xxx__(expr)) 313 314 slice = augassign.node 315 store_expr = StoreTemp(index="expr", expr=self.dispatch(slice.expr)) 316 store_lower = StoreTemp(index="lower", expr=self.dispatch_or_none(slice.lower)) 317 store_upper = StoreTemp(index="upper", expr=self.dispatch_or_none(slice.upper)) 318 node_slice = self._visitSlice(LoadTemp(index="expr"), LoadTemp(index="lower"), LoadTemp(index="upper"), "OP_APPLY") 319 get_incremented = StoreTemp( 320 expr=Invoke(expr=LoadAttr(expr=node_slice, name=self.augassign_methods[augassign.op]), args=[expr]) 321 ) 322 store = self._visitSlice(LoadTemp(index="expr"), LoadTemp(index="lower"), LoadTemp(index="upper"), "OP_ASSIGN", LoadTemp()) 323 result.code = [store_expr, store_lower, store_upper, get_incremented, store, 324 ReleaseTemp(index="expr"), ReleaseTemp(index="lower"), ReleaseTemp(index="upper"), ReleaseTemp()] 325 326 # Complicated augassign using subscripts: lvalue[subs] += expr 327 328 elif isinstance(augassign.node, compiler.ast.Subscript): 329 330 # <lvalue>, <subs> -> <lvalue>.__setitem__(<subs>, <lvalue>.__getitem__(<subs>).__xxx__(expr)) 331 332 subscript = augassign.node 333 store_expr = StoreTemp(index="expr", expr=self.dispatch(subscript.expr)) 334 subs = self._visitSubscriptSubs(subscript.subs) 335 store_subs = StoreTemp(index="subs", expr=subs) 336 node_subscript = self._visitSubscript(LoadTemp(index="expr"), LoadTemp(index="subs"), "OP_APPLY") 337 get_incremented = StoreTemp( 338 expr=Invoke(expr=LoadAttr(expr=node_subscript, name=self.augassign_methods[augassign.op]), args=[expr]) 339 ) 340 store = self._visitSubscript(LoadTemp(index="expr"), LoadTemp(index="subs"), "OP_ASSIGN", LoadTemp()) 341 result.code = [store_expr, store_subs, get_incremented, store, ReleaseTemp(index="expr"), ReleaseTemp(index="subs"), ReleaseTemp()] 342 343 else: 344 raise NotImplementedError, augassign.node.__class__ 345 346 return result 347 348 def visitAssign(self, assign): 349 result = Assign(assign) 350 store = StoreTemp(expr=self.dispatch(assign.expr)) 351 release = ReleaseTemp() 352 result.code = [store] + self.dispatches(assign.nodes, 0) + [release] 353 return result 354 355 def visitAssList(self, asslist, in_sequence=0): 356 if not in_sequence: 357 expr = LoadTemp(asslist) 358 else: 359 expr = Invoke(asslist, expr=LoadAttr(expr=LoadTemp(), name="next")) 360 result = Assign(asslist) 361 store = StoreTemp(expr=Invoke(expr=LoadAttr(name="__iter__", expr=expr))) 362 release = ReleaseTemp() 363 result.code = [store] + self.dispatches(asslist.nodes, 1) + [release] 364 return result 365 366 visitAssTuple = visitAssList 367 368 def _visitAssNameOrAttr(self, node, in_sequence): 369 if not in_sequence: 370 return LoadTemp(node) 371 else: 372 return Invoke(node, expr=LoadAttr(expr=LoadTemp(), name="next")) 373 374 def visitAssName(self, assname, in_sequence=0): 375 expr = self._visitAssNameOrAttr(assname, in_sequence) 376 result = StoreName(assname, name=assname.name, expr=expr) 377 return result 378 379 def visitAssAttr(self, assattr, in_sequence=0): 380 expr = self._visitAssNameOrAttr(assattr, in_sequence) 381 lvalue = self.dispatch(assattr.expr) 382 result = StoreAttr(assattr, name=assattr.attrname, lvalue=lvalue, expr=expr) 383 return result 384 385 def _visitSlice(self, expr, lower, upper, flags, value=None): 386 if flags == "OP_ASSIGN": 387 args = [value] 388 result = Invoke(expr=LoadAttr(expr=expr, name="__setslice__")) 389 elif flags == "OP_APPLY": 390 args = [] 391 result = Invoke(expr=LoadAttr(expr=expr, name="__getslice__")) 392 elif flags == "OP_DELETE": 393 args = [] 394 result = Invoke(expr=LoadAttr(expr=expr, name="__delslice__")) 395 else: 396 raise NotImplementedError, flags 397 398 # Add the dimensions. 399 400 args.insert(0, lower) 401 args.insert(1, upper) 402 403 result.args = args 404 return result 405 406 def visitSlice(self, slice, in_sequence=0): 407 value = self._visitAssNameOrAttr(slice, in_sequence) 408 return self._visitSlice(self.dispatch(slice.expr), self.dispatch_or_none(slice.lower), self.dispatch_or_none(slice.upper), slice.flags, value) 409 410 def _visitSubscript(self, expr, subs, flags, value=None): 411 if flags == "OP_ASSIGN": 412 args = [value] 413 result = Invoke(expr=LoadAttr(expr=expr, name="__setitem__")) 414 elif flags == "OP_APPLY": 415 args = [] 416 result = Invoke(expr=LoadAttr(expr=expr, name="__getitem__")) 417 elif flags == "OP_DELETE": 418 args = [] 419 result = Invoke(expr=LoadAttr(expr=expr, name="__delitem__")) 420 else: 421 raise NotImplementedError, flags 422 423 # Add the dimensions. 424 425 args.insert(0, subs) 426 427 result.args = args 428 return result 429 430 def _visitSubscriptSubs(self, subs): 431 if len(subs) == 1: 432 return self.dispatch(subs[0]) 433 else: 434 return Invoke(expr=LoadName(name="Tuple"), args=self.dispatches(subs)) 435 436 def visitSubscript(self, subscript, in_sequence=0): 437 value = self._visitAssNameOrAttr(subscript, in_sequence) 438 subs = self._visitSubscriptSubs(subscript.subs) 439 return self._visitSubscript(self.dispatch(subscript.expr), subs, subscript.flags, value) 440 441 # Invocation and subprogram transformations. 442 443 def _visitFunction(self, function, subprogram): 444 if function.flags & 4 != 0: has_star = 1 445 else: has_star = 0 446 if function.flags & 8 != 0: has_dstar = 1 447 else: has_dstar = 0 448 ndefaults = len(function.defaults) 449 npositional = len(function.argnames) - has_star - has_dstar 450 if has_star: star = function.argnames[npositional] 451 else: star = None 452 if has_dstar: dstar = function.argnames[npositional + has_star] 453 else: dstar = None 454 455 params = [] 456 for i in range(0, npositional - ndefaults): 457 params.append((function.argnames[i], None)) 458 459 # NOTE: Fix/process defaults. 460 461 for i in range(0, ndefaults): 462 default = function.defaults[i] 463 if default is not None: 464 params.append((function.argnames[npositional - ndefaults + i], self.dispatch(default))) 465 else: 466 params.append((function.argnames[npositional - ndefaults + i], default)) 467 468 subprogram.params = params 469 subprogram.star = star 470 subprogram.dstar = dstar 471 self.subprograms.append(subprogram) 472 473 def visitFunction(self, function): 474 475 # Make a subprogram for the function and record it outside the main 476 # tree. 477 478 subprogram = Subprogram(function, name=function.name, returns_value=1, star=None, dstar=None) 479 self.current_subprograms.append(subprogram) 480 subprogram.code = self.dispatch(function.code) 481 self.current_subprograms.pop() 482 self._visitFunction(function, subprogram) 483 484 # Make a definition of the function associating it with a name. 485 486 result = Assign(function) 487 load = LoadRef(ref=subprogram) 488 store = StoreName(name=function.name) 489 result.code = [load, store] 490 return result 491 492 def visitLambda(self, lambda_): 493 494 # Make a subprogram for the function and record it outside the main 495 # tree. 496 497 subprogram = Subprogram(lambda_, name=hex(id(lambda_)), returns_value=1, star=None, dstar=None) 498 self.current_subprograms.append(subprogram) 499 subprogram.code = [Return(expr=self.dispatch(lambda_.code))] 500 self.current_subprograms.pop() 501 self._visitFunction(lambda_, subprogram) 502 503 # Get the subprogram reference to the lambda. 504 505 return LoadRef(ref=subprogram) 506 507 def visitCallFunc(self, callfunc): 508 result = Invoke(callfunc, same_frame=0, star=None, dstar=None) 509 result.args = self.dispatches(callfunc.args) 510 if callfunc.star_args is not None: 511 result.star = self.dispatch(callfunc.star_args) 512 if callfunc.dstar_args is not None: 513 result.dstar = self.dispatch(callfunc.dstar_args) 514 result.expr = self.dispatch(callfunc.node) 515 return result 516 517 def visitWhile(self, while_): 518 519 # Make a subprogram for the block and record it outside the main tree. 520 521 subprogram = Subprogram(while_, name=hex(id(while_)), acquire_locals=1, returns_value=0, params=[], star=None, dstar=None) 522 self.current_subprograms.append(subprogram) 523 524 # Include a conditional statement in the subprogram. 525 526 test = Conditional(else_=[]) 527 test.test = Invoke(expr=LoadAttr(expr=self.dispatch(while_.test), name="__true__"), 528 params=[], star=None, dstar=None) 529 530 # Inside the conditional, add a recursive invocation to the subprogram 531 # if the test condition was satisfied. 532 533 continuation = Invoke(same_frame=1, star=None, dstar=None, args=[]) 534 continuation.expr = LoadRef(ref=subprogram) 535 test.body = self.dispatch(while_.body) + [continuation] 536 if while_.else_ is not None: 537 test.else_ = self.dispatch(while_.else_) 538 subprogram.code = [test] 539 540 self.current_subprograms.pop() 541 self.subprograms.append(subprogram) 542 543 # Make an invocation of the subprogram. 544 545 result = Invoke(while_, same_frame=1, produces_result=0, star=None, dstar=None, args=[]) 546 result.expr = LoadRef(ref=subprogram) 547 return result 548 549 def visitFor(self, for_): 550 551 # Make a subprogram for the block and record it outside the main tree. 552 553 subprogram = Subprogram(for_, name=hex(id(for_)), acquire_locals=1, returns_value=0, params=[], star=None, dstar=None) 554 self.current_subprograms.append(subprogram) 555 556 # Wrap the assignment in a try...except statement. 557 558 try_except = Try(body=[], handlers=[], else_=[], finally_=[]) 559 except_spec = Invoke(expr=LoadName(name="Tuple"), params=[LoadName(name="StopIteration")]) 560 stopiteration = Except(spec=except_spec) 561 stopiteration.code = self.dispatch(for_.else_) 562 try_except.handlers = [stopiteration] 563 564 assign = Assign() 565 assign.code = [ 566 StoreTemp(expr=Invoke(expr=LoadAttr(expr=LoadTemp(), name="next"))), 567 self.dispatch(for_.assign), 568 ReleaseTemp() 569 ] 570 571 # Inside the conditional, add a recursive invocation to the subprogram 572 # if the test condition was satisfied. 573 574 continuation = Invoke(same_frame=1, produces_result=0, star=None, dstar=None, args=[]) 575 continuation.expr = LoadRef(ref=subprogram) 576 try_except.body = [assign] + self.dispatch(for_.body) + [continuation] 577 subprogram.code = [try_except] 578 579 self.subprograms.append(subprogram) 580 self.current_subprograms.pop() 581 582 # Obtain an iterator for the sequence involved. 583 # Then, make an invocation of the subprogram. 584 585 result = Assign(for_) 586 result.code = [ 587 StoreTemp(expr=Invoke(expr=LoadAttr(name="__iter__", expr=self.dispatch(for_.list)))), 588 Invoke(expr=LoadRef(ref=subprogram), same_frame=1, produces_result=0, star=None, dstar=None, args=[]), 589 ReleaseTemp() 590 ] 591 return result 592 593 # Exception node transformations. 594 595 def visitTryExcept(self, tryexcept): 596 result = Try(tryexcept, body=[], handlers=[], else_=[], finally_=[]) 597 if tryexcept.body is not None: 598 result.body = self.dispatch(tryexcept.body) 599 if tryexcept.else_ is not None: 600 result.else_ = self.dispatch(tryexcept.else_) 601 handlers = [] 602 for spec, assign, stmt in tryexcept.handlers: 603 get_exc = Assign() 604 get_exc.code = [StoreTemp(expr=LoadExc())] 605 if assign is not None: 606 get_exc.code.append(self.dispatch(assign)) 607 get_exc.code.append(ReleaseTemp()) 608 handler = Except() 609 if spec is not None: 610 handler.spec = self.dispatch(spec) 611 handler.code = [get_exc] + self.dispatch(stmt) 612 handlers.append(handler) 613 result.handlers = handlers 614 return result 615 616 def visitTryFinally(self, tryfinally): 617 result = Try(tryfinally, body=[], handlers=[], else_=[], finally_=[]) 618 if tryfinally.body is not None: 619 result.body = self.dispatch(tryfinally.body) 620 if tryfinally.final is not None: 621 result.finally_ = self.dispatch(tryfinally.final) 622 return result 623 624 # vim: tabstop=4 expandtab shiftwidth=4