diff --git a/IPython/core/splitinput.py b/IPython/core/splitinput.py index a8c680e..7b95772 100644 --- a/IPython/core/splitinput.py +++ b/IPython/core/splitinput.py @@ -44,7 +44,7 @@ from IPython.utils.encoding import get_stream_enc line_split = re.compile(""" ^(\s*) # any leading space ([,;/%]|!!?|\?\??)? # escape character or characters - \s*(%?[\w\.\*]*) # function/method, possibly with leading % + \s*(%{0,2}[\w\.\*]*) # function/method, possibly with leading % # to correctly treat things like '?%magic' (.*?$|$) # rest of line """, re.VERBOSE) diff --git a/IPython/core/tests/test_splitinput.py b/IPython/core/tests/test_splitinput.py index cfc7209..4c31b0e 100644 --- a/IPython/core/tests/test_splitinput.py +++ b/IPython/core/tests/test_splitinput.py @@ -20,7 +20,10 @@ tests = [ (' ;ls', (' ', ';', 'ls', '')), ('f.g(x)', ('', '', 'f.g', '(x)')), ('f.g (x)', ('', '', 'f.g', '(x)')), - ('?%hist', ('', '?', '%hist', '')), + ('?%hist1', ('', '?', '%hist1', '')), + ('?%%hist2', ('', '?', '%%hist2', '')), + ('??%hist3', ('', '??', '%hist3', '')), + ('??%%hist4', ('', '??', '%%hist4', '')), ('?x*', ('', '?', 'x*', '')), ] if py3compat.PY3: