From 531b64429738b28920669157970084bcd1a2a2e5 2011-04-10 10:41:04 From: Thomas Kluyver Date: 2011-04-10 10:41:04 Subject: [PATCH] Don't increment execution_count on empty cells. +test. --- diff --git a/IPython/core/interactiveshell.py b/IPython/core/interactiveshell.py index 5af556b..f308f8c 100644 --- a/IPython/core/interactiveshell.py +++ b/IPython/core/interactiveshell.py @@ -2118,6 +2118,9 @@ class InteractiveShell(Configurable, Magic): history. For user code calling back into IPython's machinery, this should be set to False. """ + if not cell.strip(): + return + raw_cell = cell with self.builtin_trap: cell = self.prefilter_manager.prefilter_lines(cell) diff --git a/IPython/core/tests/test_interactiveshell.py b/IPython/core/tests/test_interactiveshell.py index 2a3b95c..6c8fb79 100644 --- a/IPython/core/tests/test_interactiveshell.py +++ b/IPython/core/tests/test_interactiveshell.py @@ -41,7 +41,9 @@ class InteractiveShellTestCase(unittest.TestCase): """Just make sure we don't get a horrible error with a blank cell of input. Yes, I did overlook that.""" ip = get_ipython() + old_xc = ip.execution_count ip.run_cell('') + self.assertEquals(ip.execution_count, old_xc) def test_run_cell_multiline(self): """Multi-block, multi-line cells must execute correctly.