Show More
@@ -2263,7 +2263,7 b' class InteractiveShell(SingletonConfigurable, Magic):' | |||||
2263 | cell = self.prefilter_manager.prefilter_lines(cell) + '\n' |
|
2263 | cell = self.prefilter_manager.prefilter_lines(cell) + '\n' | |
2264 | except AliasError as e: |
|
2264 | except AliasError as e: | |
2265 | error(e) |
|
2265 | error(e) | |
2266 | prefilter_failed=True |
|
2266 | prefilter_failed = True | |
2267 | except Exception: |
|
2267 | except Exception: | |
2268 | # don't allow prefilter errors to crash IPython |
|
2268 | # don't allow prefilter errors to crash IPython | |
2269 | self.showtraceback() |
|
2269 | self.showtraceback() | |
@@ -2294,7 +2294,7 b' class InteractiveShell(SingletonConfigurable, Magic):' | |||||
2294 | return None |
|
2294 | return None | |
2295 |
|
2295 | |||
2296 | self.run_ast_nodes(code_ast.body, cell_name, |
|
2296 | self.run_ast_nodes(code_ast.body, cell_name, | |
2297 |
|
|
2297 | interactivity="last_expr") | |
2298 |
|
2298 | |||
2299 | # Execute any registered post-execution functions. |
|
2299 | # Execute any registered post-execution functions. | |
2300 | for func, status in self._post_execute.iteritems(): |
|
2300 | for func, status in self._post_execute.iteritems(): | |
@@ -2351,18 +2351,30 b' class InteractiveShell(SingletonConfigurable, Magic):' | |||||
2351 | raise ValueError("Interactivity was %r" % interactivity) |
|
2351 | raise ValueError("Interactivity was %r" % interactivity) | |
2352 |
|
2352 | |||
2353 | exec_count = self.execution_count |
|
2353 | exec_count = self.execution_count | |
2354 |
|
2354 | |||
2355 | for i, node in enumerate(to_run_exec): |
|
2355 | try: | |
2356 | mod = ast.Module([node]) |
|
2356 | for i, node in enumerate(to_run_exec): | |
2357 | code = self.compile(mod, cell_name, "exec") |
|
2357 | mod = ast.Module([node]) | |
2358 | if self.run_code(code): |
|
2358 | code = self.compile(mod, cell_name, "exec") | |
2359 |
|
|
2359 | if self.run_code(code): | |
2360 |
|
2360 | return True | ||
2361 | for i, node in enumerate(to_run_interactive): |
|
2361 | ||
2362 | mod = ast.Interactive([node]) |
|
2362 | for i, node in enumerate(to_run_interactive): | |
2363 | code = self.compile(mod, cell_name, "single") |
|
2363 | mod = ast.Interactive([node]) | |
2364 | if self.run_code(code): |
|
2364 | code = self.compile(mod, cell_name, "single") | |
2365 |
|
|
2365 | if self.run_code(code): | |
|
2366 | return True | |||
|
2367 | except: | |||
|
2368 | # It's possible to have exceptions raised here, typically by | |||
|
2369 | # compilation of odd code (such as a naked 'return' outside a | |||
|
2370 | # function) that did parse but isn't valid. Typically the exception | |||
|
2371 | # is a SyntaxError, but it's safest just to catch anything and show | |||
|
2372 | # the user a traceback. | |||
|
2373 | ||||
|
2374 | # We do only one try/except outside the loop to minimize the impact | |||
|
2375 | # on runtime, and also because if any node in the node list is | |||
|
2376 | # broken, we should stop execution completely. | |||
|
2377 | self.showtraceback() | |||
2366 |
|
2378 | |||
2367 | return False |
|
2379 | return False | |
2368 |
|
2380 |
General Comments 0
You need to be logged in to leave comments.
Login now