diff --git a/IPython/core/inputsplitter.py b/IPython/core/inputsplitter.py index e78ed2e..68b5fc3 100644 --- a/IPython/core/inputsplitter.py +++ b/IPython/core/inputsplitter.py @@ -840,7 +840,7 @@ class IPythonInputSplitter(InputSplitter): # If the entire input block is a cell magic, return after handling it # as the rest of the transformation logic should be skipped. if lines.startswith('%%') and not \ - (len(lines.splitlines()) == 1 and lines.endswith('?')): + (len(lines.splitlines()) == 1 and lines.strip().endswith('?')): return self._handle_cell_magic(lines) # In line mode, a cell magic can arrive in separate pieces diff --git a/IPython/core/tests/test_inputsplitter.py b/IPython/core/tests/test_inputsplitter.py index f5b6599..2eda04c 100644 --- a/IPython/core/tests/test_inputsplitter.py +++ b/IPython/core/tests/test_inputsplitter.py @@ -624,7 +624,7 @@ class IPythonInputTestCase(InputSplitterTestCase): if raw.startswith(' '): continue - isp.push(raw) + isp.push(raw+'\n') out, out_raw = isp.source_raw_reset() self.assertEqual(out.rstrip(), out_t, tt.pair_fail_msg.format("inputsplitter",raw, out_t, out))