| 305 | self.ast_callback(exec_ast, None) |
| 306 | |
| 307 | def ast_callback(self, exec_ast, eval_ast): |
| 308 | if self.spy: |
| 309 | try: |
| 310 | # Mush the two AST chunks into a single module for |
| 311 | # conversion into Python. |
| 312 | new_ast = ast.Module( |
| 313 | exec_ast.body |
| 314 | + ([] if eval_ast is None else [ast.Expr(eval_ast.body)]), |
| 315 | type_ignores=[], |
| 316 | ) |
| 317 | print(ast.unparse(new_ast)) |
| 318 | print(self.spy_delimiter) |
| 319 | except Exception: |
| 320 | msg = "Exception in AST callback:\n{}\n".format(traceback.format_exc()) |
| 321 | self.write(msg) |
| 322 | |
| 323 | def _error_wrap(self, exc_info_override=False, *args, **kwargs): |
| 324 | # When `exc_info_override` is true, use a traceback that |