From 7fe4c5763f17a01fa6cf112560974bfe8f39891e 2011-04-08 00:02:18 From: MinRK Date: 2011-04-08 00:02:18 Subject: [PATCH] let add_history take strings for pyreadline <= 1.5 --- diff --git a/IPython/utils/rlineimpl.py b/IPython/utils/rlineimpl.py index 25cae5c..042b560 100644 --- a/IPython/utils/rlineimpl.py +++ b/IPython/utils/rlineimpl.py @@ -21,9 +21,21 @@ except ImportError: from pyreadline import * import pyreadline as _rl have_readline = True - except ImportError: + except ImportError: have_readline = False +if have_readline and hasattr(_rl, 'rlmain'): + # patch add_history to allow for strings in pyreadline <= 1.5: + # fix copied from pyreadline 1.6 + import pyreadline + if pyreadline.release.version <= '1.5': + def add_history(line): + """add a line to the history buffer.""" + from pyreadline import lineobj + if not isinstance(line, lineobj.TextLine): + line = lineobj.TextLine(line) + return _rl.add_history(line) + if sys.platform == 'win32' and have_readline: try: _outputfile=_rl.GetOutputFile()