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