##// END OF EJS Templates
Fix quitting: now, typing bare 'exit' or 'quit' unconditionally quits....
Fernando Perez -
Show More
@@ -137,8 +137,7 b' class CommandChainDispatcher:'
137 137 for prio,cmd in self.chain:
138 138 #print "prio",prio,"cmd",cmd #dbg
139 139 try:
140 ret = cmd(*args, **kw)
141 return ret
140 return cmd(*args, **kw)
142 141 except TryNext, exc:
143 142 if exc.args or exc.kwargs:
144 143 args = exc.args
@@ -2461,7 +2461,7 b' class InteractiveShell(Component, Magic):'
2461 2461 #-------------------------------------------------------------------------
2462 2462
2463 2463 def ask_exit(self):
2464 """ Call for exiting. Can be overiden and used as a callback. """
2464 """ Ask the shell to exit. Can be overiden and used as a callback. """
2465 2465 self.exit_now = True
2466 2466
2467 2467 def exit(self):
@@ -2533,20 +2533,7 b' Defaulting color scheme to \'NoColor\'"""'
2533 2533 self.shell.pprint = 1 - self.shell.pprint
2534 2534 print 'Pretty printing has been turned', \
2535 2535 ['OFF','ON'][self.shell.pprint]
2536
2537 def magic_exit(self, parameter_s=''):
2538 """Exit IPython, confirming if configured to do so.
2539
2540 You can configure whether IPython asks for confirmation upon exit by
2541 setting the confirm_exit flag in the ipythonrc file."""
2542
2543 self.shell.exit()
2544
2545 def magic_quit(self, parameter_s=''):
2546 """Exit IPython, confirming if configured to do so (like %exit)"""
2547
2548 self.shell.exit()
2549
2536
2550 2537 def magic_Exit(self, parameter_s=''):
2551 2538 """Exit IPython without confirmation."""
2552 2539
@@ -533,6 +533,20 b' class CachedOutput:'
533 533 except KeyError:
534 534 pass
535 535 if arg is not None:
536
537 # and now call a possibly user-defined print mechanism
538 try:
539 manipulated_val = self.display(arg)
540 except TypeError:
541 # If the user's display hook didn't return a string we can
542 # print, we're done. Happens commonly if they return None
543 return
544
545 # user display hooks can change the variable to be stored in
546 # output history
547 if manipulated_val is not None:
548 arg = manipulated_val
549
536 550 cout_write = Term.cout.write # fast lookup
537 551 # first handle the cache and counters
538 552
@@ -552,15 +566,6 b' class CachedOutput:'
552 566 else:
553 567 print "self.do_full_cache = False"
554 568
555 # and now call a possibly user-defined print mechanism
556 manipulated_val = self.display(arg)
557
558 # user display hooks can change the variable to be stored in
559 # output history
560
561 if manipulated_val is not None:
562 arg = manipulated_val
563
564 569 # avoid recursive reference when displaying _oh/Out
565 570 if arg is not self.user_ns['_oh']:
566 571 self.update(arg)
@@ -1,10 +1,10 b''
1 #!/usr/bin/env python
2 # encoding: utf-8
1 # coding: utf-8
3 2 """
4 3 A simple class for quitting IPython.
5 4
6 Authors:
7
5 Authors
6 -------
7 * Fernando Perez
8 8 * Brian Granger
9 9 """
10 10
@@ -19,6 +19,7 b' Authors:'
19 19 # Imports
20 20 #-----------------------------------------------------------------------------
21 21
22 import sys
22 23
23 24 class Quitter(object):
24 25 """Simple class to handle exit, similar to Python 2.5's.
@@ -30,9 +31,10 b' class Quitter(object):'
30 31 self.shell = shell
31 32 self.name = name
32 33
33 def __repr__(self):
34 def __str__(self):
34 35 return 'Type %s() to exit.' % self.name
35 __str__ = __repr__
36 36
37 37 def __call__(self):
38 self.shell.exit() No newline at end of file
38 self.shell.ask_exit()
39
40 __repr__ = __call__
@@ -11,6 +11,7 b' from cStringIO import StringIO'
11 11
12 12 import nose.tools as nt
13 13
14 from IPython.core.iplib import get_ipython
14 15 from IPython.utils.platutils import find_cmd, get_long_path_name
15 16 from IPython.testing import decorators as dec
16 17 from IPython.testing import tools as tt
General Comments 0
You need to be logged in to leave comments. Login now