diff --git a/IPython/core/inputsplitter.py b/IPython/core/inputsplitter.py index f57ef92..d4a393e 100644 --- a/IPython/core/inputsplitter.py +++ b/IPython/core/inputsplitter.py @@ -506,7 +506,8 @@ class InputSplitter(object): line_split = re.compile(""" ^(\s*) # any leading space ([,;/%]|!!?|\?\??) # escape character or characters - \s*([\w\.]*) # function/method part (mix of \w and '.') + \s*(%?[\w\.]*) # function/method, possibly with leading % + # to correctly treat things like '?%magic' (\s+.*$|$) # rest of line """, re.VERBOSE) @@ -551,6 +552,8 @@ def split_user_input(line): ('', '', 'f.g(x)', '') >>> split_user_input('f.g (x)') ('', '', 'f.g', '(x)') + >>> split_user_input('?%hist') + ('', '?', '%hist', '') """ match = line_split.match(line) if match: diff --git a/IPython/core/tests/test_inputsplitter.py b/IPython/core/tests/test_inputsplitter.py index c2ebe0b..d2cb1e7 100644 --- a/IPython/core/tests/test_inputsplitter.py +++ b/IPython/core/tests/test_inputsplitter.py @@ -443,6 +443,7 @@ syntax = \ ('??x2', 'get_ipython().magic("pinfo2 x2")'), ('x3?', 'get_ipython().magic("pinfo x3")'), ('x4??', 'get_ipython().magic("pinfo2 x4")'), + ('%hist?', 'get_ipython().magic("pinfo %hist")'), ], # Explicit magic calls