##// END OF EJS Templates
remove rest of readline, pass II
Matthias Bussonnier -
Show More
@@ -62,7 +62,6 b' from IPython.utils import PyColorize'
62 62 from IPython.utils import io
63 63 from IPython.utils import py3compat
64 64 from IPython.utils import openpy
65 from IPython.utils.contexts import NoOpContext
66 65 from IPython.utils.decorators import undoc
67 66 from IPython.utils.io import ask_yes_no
68 67 from IPython.utils.ipstruct import Struct
@@ -574,9 +573,6 b' class InteractiveShell(SingletonConfigurable):'
574 573 self.tempfiles = []
575 574 self.tempdirs = []
576 575
577 # Keep track of readline usage (later set by init_readline)
578 self.has_readline = False
579
580 576 # keep track of where we started running (mainly for crash post-mortem)
581 577 # This is not being used anywhere currently.
582 578 self.starting_dir = py3compat.getcwd()
@@ -659,11 +655,8 b' class InteractiveShell(SingletonConfigurable):'
659 655 # override sys.stdout and sys.stderr themselves, you need to do that
660 656 # *before* instantiating this class, because io holds onto
661 657 # references to the underlying streams.
662 if (sys.platform == 'win32' or sys.platform == 'cli') and self.has_readline:
663 io.stdout = io.stderr = io.IOStream(self.readline._outputfile)
664 else:
665 io.stdout = io.IOStream(sys.stdout)
666 io.stderr = io.IOStream(sys.stderr)
658 io.stdout = io.IOStream(sys.stdout)
659 io.stderr = io.IOStream(sys.stderr)
667 660
668 661 def init_prompts(self):
669 662 # Set system prompts, so that scripts can decide if they are running
@@ -984,9 +977,7 b' class InteractiveShell(SingletonConfigurable):'
984 977 error('No traceback has been produced, nothing to debug.')
985 978 return
986 979
987
988 with self.readline_no_record:
989 self.InteractiveTB.debugger(force=True)
980 self.InteractiveTB.debugger(force=True)
990 981
991 982 #-------------------------------------------------------------------------
992 983 # Things related to IPython's various namespaces
@@ -1889,10 +1880,7 b' class InteractiveShell(SingletonConfigurable):'
1889 1880
1890 1881 def init_readline(self):
1891 1882 """Moved to terminal subclass, here only to simplify the init logic."""
1892 self.readline = None
1893 1883 # Set a number of methods that depend on readline to be no-op
1894 self.readline_no_record = NoOpContext()
1895 self.set_readline_completer = no_op
1896 1884 self.set_custom_completer = no_op
1897 1885
1898 1886 @skip_doctest
@@ -1929,7 +1917,7 b' class InteractiveShell(SingletonConfigurable):'
1929 1917 self.Completer = IPCompleter(shell=self,
1930 1918 namespace=self.user_ns,
1931 1919 global_namespace=self.user_global_ns,
1932 use_readline=self.has_readline,
1920 use_readline=False,
1933 1921 parent=self,
1934 1922 )
1935 1923 self.configurables.append(self.Completer)
@@ -705,55 +705,54 b' python-profiler package from non-free.""")'
705 705
706 706 try:
707 707 stats = None
708 with self.shell.readline_no_record:
709 if 'p' in opts:
710 stats = self._run_with_profiler(code, opts, code_ns)
708 if 'p' in opts:
709 stats = self._run_with_profiler(code, opts, code_ns)
710 else:
711 if 'd' in opts:
712 bp_file, bp_line = parse_breakpoint(
713 opts.get('b', ['1'])[0], filename)
714 self._run_with_debugger(
715 code, code_ns, filename, bp_line, bp_file)
711 716 else:
712 if 'd' in opts:
713 bp_file, bp_line = parse_breakpoint(
714 opts.get('b', ['1'])[0], filename)
715 self._run_with_debugger(
716 code, code_ns, filename, bp_line, bp_file)
717 if 'm' in opts:
718 def run():
719 self.shell.safe_run_module(modulename, prog_ns)
717 720 else:
718 if 'm' in opts:
719 def run():
720 self.shell.safe_run_module(modulename, prog_ns)
721 else:
722 if runner is None:
723 runner = self.default_runner
724 if runner is None:
725 runner = self.shell.safe_execfile
726
727 def run():
728 runner(filename, prog_ns, prog_ns,
729 exit_ignore=exit_ignore)
730
731 if 't' in opts:
732 # timed execution
733 try:
734 nruns = int(opts['N'][0])
735 if nruns < 1:
736 error('Number of runs must be >=1')
737 return
738 except (KeyError):
739 nruns = 1
740 self._run_with_timing(run, nruns)
741 else:
742 # regular execution
743 run()
744
745 if 'i' in opts:
746 self.shell.user_ns['__name__'] = __name__save
747 else:
748 # update IPython interactive namespace
721 if runner is None:
722 runner = self.default_runner
723 if runner is None:
724 runner = self.shell.safe_execfile
725
726 def run():
727 runner(filename, prog_ns, prog_ns,
728 exit_ignore=exit_ignore)
729
730 if 't' in opts:
731 # timed execution
732 try:
733 nruns = int(opts['N'][0])
734 if nruns < 1:
735 error('Number of runs must be >=1')
736 return
737 except (KeyError):
738 nruns = 1
739 self._run_with_timing(run, nruns)
740 else:
741 # regular execution
742 run()
743
744 if 'i' in opts:
745 self.shell.user_ns['__name__'] = __name__save
746 else:
747 # update IPython interactive namespace
749 748
750 # Some forms of read errors on the file may mean the
751 # __name__ key was never set; using pop we don't have to
752 # worry about a possible KeyError.
753 prog_ns.pop('__name__', None)
749 # Some forms of read errors on the file may mean the
750 # __name__ key was never set; using pop we don't have to
751 # worry about a possible KeyError.
752 prog_ns.pop('__name__', None)
754 753
755 with preserve_keys(self.shell.user_ns, '__file__'):
756 self.shell.user_ns.update(prog_ns)
754 with preserve_keys(self.shell.user_ns, '__file__'):
755 self.shell.user_ns.update(prog_ns)
757 756 finally:
758 757 # It's a bit of a mystery why, but __builtins__ can change from
759 758 # being a module to becoming a dict missing some key data after
@@ -343,12 +343,6 b' class InteractiveShellApp(Configurable):'
343 343 except:
344 344 self.log.warning("Unknown error in handling PYTHONSTARTUP file %s:", python_startup)
345 345 self.shell.showtraceback()
346 finally:
347 # Many PYTHONSTARTUP files set up the readline completions,
348 # but this is often at odds with IPython's own completions.
349 # Do not allow PYTHONSTARTUP to set up readline.
350 if self.shell.has_readline:
351 self.shell.set_readline_completer()
352 346
353 347 startup_files += glob.glob(os.path.join(startup_dir, '*.py'))
354 348 startup_files += glob.glob(os.path.join(startup_dir, '*.ipy'))
@@ -115,7 +115,6 b' from inspect import getsourcefile, getfile, getmodule, \\'
115 115 ismodule, isclass, ismethod, isfunction, istraceback, isframe, iscode
116 116
117 117 # IPython's own modules
118 # Modified pdb which doesn't damage IPython's readline handling
119 118 from IPython import get_ipython
120 119 from IPython.core import debugger
121 120 from IPython.core.display_trap import DisplayTrap
@@ -140,9 +140,6 b' class InteractiveShellEmbed(TerminalInteractiveShell):'
140 140 if dummy or (dummy != 0 and self.dummy_mode):
141 141 return
142 142
143 if self.has_readline:
144 self.set_readline_completer()
145
146 143 # self.banner is auto computed
147 144 if header:
148 145 self.old_banner2 = self.banner2
General Comments 0
You need to be logged in to leave comments. Login now