diff --git a/IPython/iplib.py b/IPython/iplib.py index e4605d4..7acf3dc 100644 --- a/IPython/iplib.py +++ b/IPython/iplib.py @@ -6,7 +6,7 @@ Requires Python 2.3 or newer. This file contains all the classes and helper functions specific to IPython. -$Id: iplib.py 1788 2006-09-27 07:15:44Z fperez $ +$Id: iplib.py 1803 2006-10-03 16:29:50Z vivainio $ """ #***************************************************************************** @@ -1523,6 +1523,9 @@ want to merge them back into the new files.""" % locals() prompt = self.hooks.generate_prompt(False) try: line = self.raw_input(prompt,more) + if self.exit_now: + # quick exit on sys.std[in|out] close + break if self.autoindent: self.readline_startup_hook(None) except KeyboardInterrupt: @@ -1823,7 +1826,13 @@ want to merge them back into the new files.""" % locals() continuation in a sequence of inputs. """ - line = raw_input_original(prompt) + try: + line = raw_input_original(prompt) + except ValueError: + warn("\n********\nYou or a %run:ed script called sys.stdin.close() or sys.stdout.close()!\nExiting IPython!") + self.exit_now = True + return "" + # Try to be reasonably smart about not re-indenting pasted input more # than necessary. We do this by trimming out the auto-indent initial diff --git a/doc/ChangeLog b/doc/ChangeLog index a2bbe9f..03c83fa 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,9 @@ +2006-10-03 Ville Vainio + + * iplib.py (raw_input, interact): Return ValueError catching for + raw_input. Fixes infinite loop for sys.stdin.close() or + sys.stdout.close(). + 2006-09-27 Fernando Perez * IPython/irunner.py (InteractiveRunner.run_source): small fixes