##// END OF EJS Templates
Defer saving raw_input to shell initialisation, so that we pick up the modified version needed for PyPy's readline to work.
Thomas Kluyver -
Show More
@@ -86,10 +86,6 b" dedent_re = re.compile(r'^\\s+raise|^\\s+return|^\\s+pass')"
86 # Utilities
86 # Utilities
87 #-----------------------------------------------------------------------------
87 #-----------------------------------------------------------------------------
88
88
89 # store the builtin raw_input globally, and use this always, in case user code
90 # overwrites it (like wx.py.PyShell does)
91 raw_input_original = raw_input
92
93 def softspace(file, newvalue):
89 def softspace(file, newvalue):
94 """Copied from code.py, to remove the dependency"""
90 """Copied from code.py, to remove the dependency"""
95
91
@@ -411,6 +407,10 b' class InteractiveShell(SingletonConfigurable, Magic):'
411 # init_readline() must come before init_io(), because init_io uses
407 # init_readline() must come before init_io(), because init_io uses
412 # readline related things.
408 # readline related things.
413 self.init_readline()
409 self.init_readline()
410 # We save this here in case user code replaces raw_input, but it needs
411 # to be after init_readline(), because PyPy's readline works by replacing
412 # raw_input.
413 self.raw_input_original = raw_input
414 # init_completer must come after init_readline, because it needs to
414 # init_completer must come after init_readline, because it needs to
415 # know whether readline is present or not system-wide to configure the
415 # know whether readline is present or not system-wide to configure the
416 # completers, since the completion machinery can now operate
416 # completers, since the completion machinery can now operate
@@ -3175,7 +3175,7 b' Defaulting color scheme to \'NoColor\'"""'
3175 from IPython.core import interactiveshell
3175 from IPython.core import interactiveshell
3176 print "Pasting code; enter '%s' alone on the line to stop." % sentinel
3176 print "Pasting code; enter '%s' alone on the line to stop." % sentinel
3177 while True:
3177 while True:
3178 l = interactiveshell.raw_input_original(':')
3178 l = self.shell.raw_input_original(':')
3179 if l == sentinel:
3179 if l == sentinel:
3180 return
3180 return
3181 else:
3181 else:
@@ -47,11 +47,6 b' def get_default_editor():'
47 ed = 'notepad' # same in Windows!
47 ed = 'notepad' # same in Windows!
48 return ed
48 return ed
49
49
50
51 # store the builtin raw_input globally, and use this always, in case user code
52 # overwrites it (like wx.py.PyShell does)
53 raw_input_original = raw_input
54
55 #-----------------------------------------------------------------------------
50 #-----------------------------------------------------------------------------
56 # Main class
51 # Main class
57 #-----------------------------------------------------------------------------
52 #-----------------------------------------------------------------------------
@@ -337,7 +332,7 b' class TerminalInteractiveShell(InteractiveShell):'
337 self.set_readline_completer()
332 self.set_readline_completer()
338
333
339 try:
334 try:
340 line = raw_input_original(prompt).decode(self.stdin_encoding)
335 line = self.raw_input_original(prompt).decode(self.stdin_encoding)
341 except ValueError:
336 except ValueError:
342 warn("\n********\nYou or a %run:ed script called sys.stdin.close()"
337 warn("\n********\nYou or a %run:ed script called sys.stdin.close()"
343 " or sys.stdout.close()!\nExiting IPython!")
338 " or sys.stdout.close()!\nExiting IPython!")
General Comments 0
You need to be logged in to leave comments. Login now