diff --git a/IPython/core/history.py b/IPython/core/history.py index 029d2ba..7666731 100644 --- a/IPython/core/history.py +++ b/IPython/core/history.py @@ -25,7 +25,7 @@ from IPython.config.configurable import Configurable 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 @@ class HistoryManager(Configurable): # 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) diff --git a/IPython/core/interactiveshell.py b/IPython/core/interactiveshell.py index 5218375..f61b348 100644 --- a/IPython/core/interactiveshell.py +++ b/IPython/core/interactiveshell.py @@ -86,10 +86,6 @@ dedent_re = re.compile(r'^\s+raise|^\s+return|^\s+pass') # 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 @@ class InteractiveShell(SingletonConfigurable, Magic): # 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 diff --git a/IPython/core/magic.py b/IPython/core/magic.py index c255217..64cd121 100644 --- a/IPython/core/magic.py +++ b/IPython/core/magic.py @@ -3179,7 +3179,7 @@ Defaulting color scheme to 'NoColor'""" 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: diff --git a/IPython/frontend/terminal/interactiveshell.py b/IPython/frontend/terminal/interactiveshell.py index e78f89e..253f3e4 100644 --- a/IPython/frontend/terminal/interactiveshell.py +++ b/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 @@ class TerminalInteractiveShell(InteractiveShell): 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!")