Skip to content


Subversion checkout URL

You can clone with
Download ZIP


PyPy compatibility #722

merged 2 commits into from

2 participants


So far, this just gets it to start. It still has trouble with readline, and there a lot of test failures - a combination of nose, the limitations of PyPy's numpy module, small differences in output for doctests, and unicode.

Will liaise with PyPy developers - first off, about readline, because without tab completion, one of the big advantages of IPython is missing.

Closes gh-719


The shell is now working OK with PyPy's readline. Haven't tried to make all the tests pass.


Do we want to wait for further PyPy compatibility, or should we just merge this now? It seems fine as-is to me.


I'm happy to merge this now. We can always do more later if we need to. I just made a PR to check that it was OK to store the original raw_input at instantiation, rather than at import.


Yes, I think this makes sense. I think it's actually better, because IPython should use the raw_input of the environment into which it is launched, not that of the top of the first file to import it.

@takluyver takluyver merged commit d8f3d17 into ipython:master

OK, great. I've merged it in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 22, 2011
  1. @takluyver
  2. @takluyver

    Defer saving raw_input to shell initialisation, so that we pick up th…

    takluyver authored
    …e modified version needed for PyPy's readline to work.
This page is out of date. Refresh to see the latest.
4 IPython/core/
@@ -25,7 +25,7 @@
from IPython.testing.skipdoctest import skip_doctest
from IPython.utils import io
-from IPython.utils.traitlets import Bool, Dict, Instance, Int, List, Unicode
+from IPython.utils.traitlets import Bool, Dict, Instance, Int, CInt, List, Unicode
from IPython.utils.warn import warn
@@ -63,7 +63,7 @@ def _dir_hist_default(self):
# The SQLite database
db = Instance(sqlite3.Connection)
# The number of the current session in the history database
- session_number = Int()
+ session_number = CInt()
# Should we log output to the database? (default no)
db_log_output = Bool(False, config=True)
# Write to database every x commands (higher values save disk access & power)
8 IPython/core/
@@ -86,10 +86,6 @@
# Utilities
-# store the builtin raw_input globally, and use this always, in case user code
-# overwrites it (like does)
-raw_input_original = raw_input
def softspace(file, newvalue):
"""Copied from, to remove the dependency"""
@@ -411,6 +407,10 @@ def __init__(self, config=None, ipython_dir=None, profile_dir=None,
# init_readline() must come before init_io(), because init_io uses
# readline related things.
+ # We save this here in case user code replaces raw_input, but it needs
+ # to be after init_readline(), because PyPy's readline works by replacing
+ # raw_input.
+ self.raw_input_original = raw_input
# init_completer must come after init_readline, because it needs to
# know whether readline is present or not system-wide to configure the
# completers, since the completion machinery can now operate
2  IPython/core/
@@ -3175,7 +3175,7 @@ def _get_pasted_lines(self, sentinel):
from IPython.core import interactiveshell
print "Pasting code; enter '%s' alone on the line to stop." % sentinel
while True:
- l = interactiveshell.raw_input_original(':')
+ l =':')
if l == sentinel:
7 IPython/frontend/terminal/
@@ -47,11 +47,6 @@ def get_default_editor():
ed = 'notepad' # same in Windows!
return ed
-# store the builtin raw_input globally, and use this always, in case user code
-# overwrites it (like does)
-raw_input_original = raw_input
# Main class
@@ -337,7 +332,7 @@ def raw_input(self, prompt=''):
- line = raw_input_original(prompt).decode(self.stdin_encoding)
+ line = self.raw_input_original(prompt).decode(self.stdin_encoding)
except ValueError:
warn("\n********\nYou or a %run:ed script called sys.stdin.close()"
" or sys.stdout.close()!\nExiting IPython!")
Something went wrong with that request. Please try again.