Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

Fix missing history in cell execution mode.

Also cleaned up and commented run_cell a little better, no need to run
using map() when a single run_code call suffices.
  • Loading branch information...
commit 205d1241376996eb8ca5e72c7c29d4689a80fbb8 1 parent 3658d7b
@fperez fperez authored
Showing with 16 additions and 3 deletions.
  1. +16 −3 IPython/core/
19 IPython/core/
@@ -2093,20 +2093,28 @@ def run_cell(self, cell):
cell : str
A single or multiline string.
+ # We need to break up the input into executable blocks that can be run
+ # in 'single' mode, to provide comfortable user behavior.
blocks = self.input_splitter.split_blocks(cell)
if not blocks:
+ # Single-block input should behave like an interactive prompt
if len(blocks) == 1:
+ # In multi-block input, if the last block is a simple (one-two lines)
+ # expression, run it in single mode so it produces output. Otherwise
+ # just feed the whole thing to runcode.
+ # This seems like a reasonable usability design.
last = blocks[-1]
if len(last.splitlines()) < 2:
- map(self.runcode, blocks[:-1])
+ self.runcode('\n'.join(blocks[:-1]))
- map(self.runcode, blocks)
+ self.runcode(cell)
def runlines(self, lines, clean=False):
"""Run a string of one or more lines of source.
@@ -2226,6 +2234,11 @@ def runcode(self, code_obj):
- 1: an error occurred.
+ # It's also possible that we've been fed a plain string. In that case,
+ # we must store it in the input history.
+ if isinstance(code_obj, basestring):
+ self.input_hist_raw.append(code_obj)
# Set our own excepthook in case the user code tries to call it
# directly, so that the IPython crash handler doesn't get triggered
old_excepthook,sys.excepthook = sys.excepthook, self.excepthook

0 comments on commit 205d124

Please sign in to comment.
Something went wrong with that request. Please try again.