[IPython-dev] closing sys.stdout

Fernando Perez fperez.net at gmail.com
Tue Sep 19 13:41:46 EDT 2006


On 9/19/06, Ville M. Vainio <vivainio at gmail.com> wrote:
> On 9/19/06, John Hunter <jdhunter at ace.bsd.uchicago.edu> wrote:
>
> > ipython may want to hijack sys.stdout.close to prevent this kind of thing...
>
> Good call, though I can't see *why* this dumps core instead of
> something more orderly...

I'd say this is a python bug, but we'd have to track it better to
submit a report.

I managed to reproduce it from a plain python console, so this is
probably worth reporting.  I don't have 2.5 on this machine, so I
can't test, but here it is from a plain python console:

planck[freeslater]> python
Python 2.3.4 (#1, Feb  2 2005, 12:11:53)
[GCC 3.4.2 20041017 (Red Hat 3.4.2-6.fc3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import code
>>> code.I
code.InteractiveConsole      code.InteractiveInterpreter
>>> c=code.InteractiveConsole()
>>> c.interact()
Python 2.3.4 (#1, Feb  2 2005, 12:11:53)
[GCC 3.4.2 20041017 (Red Hat 3.4.2-6.fc3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> import sys
>>> sys.std
sys.stderr  sys.stdin   sys.stdout
>>> sys.stdout.close()
Segmentation fault (core dumped)


This is /certainly/ a pure python bug, though we should protect
against it until they get around to fixing it.  I'll try to test 2.5
at home tonight and will file a bug report at SF against python.

Cheers,

f



More information about the IPython-dev mailing list