##// 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 for prio,cmd in self.chain:
137 for prio,cmd in self.chain:
138 #print "prio",prio,"cmd",cmd #dbg
138 #print "prio",prio,"cmd",cmd #dbg
139 try:
139 try:
140 ret = cmd(*args, **kw)
140 return cmd(*args, **kw)
141 return ret
142 except TryNext, exc:
141 except TryNext, exc:
143 if exc.args or exc.kwargs:
142 if exc.args or exc.kwargs:
144 args = exc.args
143 args = exc.args
@@ -2461,7 +2461,7 b' class InteractiveShell(Component, Magic):'
2461 #-------------------------------------------------------------------------
2461 #-------------------------------------------------------------------------
2462
2462
2463 def ask_exit(self):
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 self.exit_now = True
2465 self.exit_now = True
2466
2466
2467 def exit(self):
2467 def exit(self):
@@ -2534,19 +2534,6 b' Defaulting color scheme to \'NoColor\'"""'
2534 print 'Pretty printing has been turned', \
2534 print 'Pretty printing has been turned', \
2535 ['OFF','ON'][self.shell.pprint]
2535 ['OFF','ON'][self.shell.pprint]
2536
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
2550 def magic_Exit(self, parameter_s=''):
2537 def magic_Exit(self, parameter_s=''):
2551 """Exit IPython without confirmation."""
2538 """Exit IPython without confirmation."""
2552
2539
@@ -533,6 +533,20 b' class CachedOutput:'
533 except KeyError:
533 except KeyError:
534 pass
534 pass
535 if arg is not None:
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 cout_write = Term.cout.write # fast lookup
550 cout_write = Term.cout.write # fast lookup
537 # first handle the cache and counters
551 # first handle the cache and counters
538
552
@@ -552,15 +566,6 b' class CachedOutput:'
552 else:
566 else:
553 print "self.do_full_cache = False"
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 # avoid recursive reference when displaying _oh/Out
569 # avoid recursive reference when displaying _oh/Out
565 if arg is not self.user_ns['_oh']:
570 if arg is not self.user_ns['_oh']:
566 self.update(arg)
571 self.update(arg)
@@ -1,10 +1,10 b''
1 #!/usr/bin/env python
1 # coding: utf-8
2 # encoding: utf-8
3 """
2 """
4 A simple class for quitting IPython.
3 A simple class for quitting IPython.
5
4
6 Authors:
5 Authors
7
6 -------
7 * Fernando Perez
8 * Brian Granger
8 * Brian Granger
9 """
9 """
10
10
@@ -19,6 +19,7 b' Authors:'
19 # Imports
19 # Imports
20 #-----------------------------------------------------------------------------
20 #-----------------------------------------------------------------------------
21
21
22 import sys
22
23
23 class Quitter(object):
24 class Quitter(object):
24 """Simple class to handle exit, similar to Python 2.5's.
25 """Simple class to handle exit, similar to Python 2.5's.
@@ -30,9 +31,10 b' class Quitter(object):'
30 self.shell = shell
31 self.shell = shell
31 self.name = name
32 self.name = name
32
33
33 def __repr__(self):
34 def __str__(self):
34 return 'Type %s() to exit.' % self.name
35 return 'Type %s() to exit.' % self.name
35 __str__ = __repr__
36
36
37 def __call__(self):
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 import nose.tools as nt
12 import nose.tools as nt
13
13
14 from IPython.core.iplib import get_ipython
14 from IPython.utils.platutils import find_cmd, get_long_path_name
15 from IPython.utils.platutils import find_cmd, get_long_path_name
15 from IPython.testing import decorators as dec
16 from IPython.testing import decorators as dec
16 from IPython.testing import tools as tt
17 from IPython.testing import tools as tt
General Comments 0
You need to be logged in to leave comments. Login now