[IPython-dev] Not crashing on exit() w/ py2.5

Ville M. Vainio vivainio at gmail.com
Tue Sep 26 17:11:34 EDT 2006


I just checked in this to avoid crashing py2.5 on exit(); raw_input
will raise ValueError because py2.5 exit() closes stdin. It's a hack,
but will do for a while.

Index: IPython/iplib.py
===================================================================
--- IPython/iplib.py    (revision 1777)
+++ IPython/iplib.py    (working copy)
@@ -1740,7 +1740,7 @@
         except SystemExit:
             self.resetbuffer()
             self.showtraceback()
-            warn("Type exit or quit to exit IPython "
+            warn("Type %exit or %quit to exit IPython "
                  "(%Exit or %Quit do so unconditionally).",level=1)
         except self.custom_exceptions:
             etype,value,tb = sys.exc_info()
@@ -1801,7 +1801,14 @@
           continuation in a sequence of inputs.
         """

-        line = raw_input_original(prompt)
+        try:
+            line = raw_input_original(prompt)
+        except ValueError:
+            # python 2.5 closes stdin on exit -> ValueError
+            # xxx should we delete 'exit' and 'quit' from builtin?
+            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


-- 
Ville M. Vainio - vivainio.googlepages.com
blog=360.yahoo.com/villevainio - g[mail | talk]='vivainio'



More information about the IPython-dev mailing list