diff --git a/IPython/core/inputtransformer.py b/IPython/core/inputtransformer.py index 6be225b..f20b1a1 100644 --- a/IPython/core/inputtransformer.py +++ b/IPython/core/inputtransformer.py @@ -453,8 +453,8 @@ def _strip_prompts(prompt_re, initial_re=None): def classic_prompt(): """Strip the >>>/... prompts of the Python interactive shell.""" # FIXME: non-capturing version (?:...) usable? - prompt_re = re.compile(r'^(>>> ?|\.\.\. ?)') - initial_re = re.compile(r'^(>>> ?)') + prompt_re = re.compile(r'^(>>>|\.\.\.)( |$)') + initial_re = re.compile(r'^>>>( |$)') return _strip_prompts(prompt_re, initial_re) @CoroutineInputTransformer.wrap diff --git a/IPython/core/tests/test_inputsplitter.py b/IPython/core/tests/test_inputsplitter.py index 79761fe..c5c841e 100644 --- a/IPython/core/tests/test_inputsplitter.py +++ b/IPython/core/tests/test_inputsplitter.py @@ -455,9 +455,9 @@ class IPythonInputTestCase(InputSplitterTestCase): isp = self.isp for raw, name, line, cell in [ ("%%cellm a\nIn[1]:", u'cellm', u'a', u'In[1]:'), - ("%%cellm \nline\n>>>hi", u'cellm', u'', u'line\n>>>hi'), - (">>>%%cellm \nline\n>>>hi", u'cellm', u'', u'line\nhi'), - ("%%cellm \n>>>hi", u'cellm', u'', u'hi'), + ("%%cellm \nline\n>>> hi", u'cellm', u'', u'line\n>>> hi'), + (">>> %%cellm \nline\n>>> hi", u'cellm', u'', u'line\nhi'), + ("%%cellm \n>>> hi", u'cellm', u'', u'hi'), ("%%cellm \nline1\nline2", u'cellm', u'', u'line1\nline2'), ("%%cellm \nline1\\\\\nline2", u'cellm', u'', u'line1\\\\\nline2'), ]: