From c983029d0fb226379c83b335e358593639a13ad0 2010-01-01 06:05:17 From: Fernando Perez Date: 2010-01-01 06:05:17 Subject: [PATCH] Fix bug where output prompts were coming *after* output values. This means that on exit/quit, we'll see something, so I added a simple 'bye' to those. Not pretty, but easier than messing with the prompt logic. --- diff --git a/IPython/core/prompts.py b/IPython/core/prompts.py index c382a9e..3e2e8b3 100644 --- a/IPython/core/prompts.py +++ b/IPython/core/prompts.py @@ -533,20 +533,6 @@ class CachedOutput: except KeyError: pass if arg is not None: - - # and now call a possibly user-defined print mechanism - try: - manipulated_val = self.display(arg) - except TypeError: - # If the user's display hook didn't return a string we can - # print, we're done. Happens commonly if they return None - return - - # user display hooks can change the variable to be stored in - # output history - if manipulated_val is not None: - arg = manipulated_val - cout_write = Term.cout.write # fast lookup # first handle the cache and counters @@ -566,6 +552,22 @@ class CachedOutput: else: print "self.do_full_cache = False" + # and now call a possibly user-defined print mechanism. Note that + # self.display typically prints as a side-effect, we don't do any + # printing to stdout here. + try: + manipulated_val = self.display(arg) + except TypeError: + # If the user's display hook didn't return a string we can + # print, we're done. Happens commonly if they return None + cout_write('\n') + return + + # user display hooks can change the variable to be stored in + # output history + if manipulated_val is not None: + arg = manipulated_val + # avoid recursive reference when displaying _oh/Out if arg is not self.user_ns['_oh']: self.update(arg) diff --git a/IPython/core/quitter.py b/IPython/core/quitter.py index 850ace2..2cf74f7 100755 --- a/IPython/core/quitter.py +++ b/IPython/core/quitter.py @@ -36,5 +36,6 @@ class Quitter(object): def __call__(self): self.shell.ask_exit() + return 'Bye.' __repr__ = __call__