rep (magic recall) under pypy #1061

Closed
hpaulj opened this Issue Nov 28, 2011 · 3 comments

Projects

None yet

2 participants

@hpaulj

IPython 0.11 and 0.12.dev running under pypy 1.6.0, magic rep does not work. More specifically

ip = get_ipython()
ip.rl_next_input = '1+3'

does nothing (i.e. does not put 1+3 on the next input line)

auto indent also does not work (since it also uses ip.readline.insert_text())
Presumably this is a pypy readline problem

@fperez
IPython member

Unfortunately I think these are really issues for pypy, not for IPython. There's nothing we can do about it, it seems the pypy readline implementation isn't complete yet.

Closing here; feel free to reopen if you have specific evidence that there's a bug we can fix from our side.

@fperez fperez closed this Nov 28, 2011
@hpaulj

I think I have a solution, but it involves changing the pypy readline.raw_input(), not anything in ipython. This raw_input() invokes the startup_hook before its reader.buffer is reset. When the buffer is reset (in reader.readline() ), any readline.insert_text() action is lost.

My solution is to clear the buffer in readline.raw_input, and then hang onto the buffer contents when readline does its reset (self.prepare() ). But I have make a new reader.readline method so I don't interfere with main pypy shell loop (which uses readline.multiline_input).

It was much easier to identify the problem by running the PyMOTW readline_hooks.py sample code than to wade through multiple levels of redirection and hook definitions in ipython. :)

@fperez
IPython member

great, at least it's a good solution for now. Eventually it might be a good idea to get these fixes integrated into pypy: its readline should behave like the python one, and that's the api ipython codes against.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment