Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

…e modified version needed for PyPy's readline to work.
  • Loading branch information...
commit d8f3d170be002b23d41a8887197cffe5977c4af8 1 parent 4d5d46f
@takluyver authored
View
8 IPython/core/interactiveshell.py
@@ -86,10 +86,6 @@
# Utilities
#-----------------------------------------------------------------------------
-# store the builtin raw_input globally, and use this always, in case user code
-# overwrites it (like wx.py.PyShell does)
-raw_input_original = raw_input
-
def softspace(file, newvalue):
"""Copied from code.py, 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.
self.init_readline()
+ # 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
View
2  IPython/core/magic.py
@@ -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 = self.shell.raw_input_original(':')
if l == sentinel:
return
else:
View
7 IPython/frontend/terminal/interactiveshell.py
@@ -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 wx.py.PyShell does)
-raw_input_original = raw_input
-
#-----------------------------------------------------------------------------
# Main class
#-----------------------------------------------------------------------------
@@ -337,7 +332,7 @@ def raw_input(self, prompt=''):
self.set_readline_completer()
try:
- 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!")
Please sign in to comment.
Something went wrong with that request. Please try again.