[IPython-dev] closing sys.stdout

José Matos jaomatos at gmail.com
Wed Sep 20 05:10:53 EDT 2006


Hi Fernando,

On 19/09/06, Fernando Perez <fperez.net at gmail.com> wrote:
> 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

This is what I get in python 2.5 (rc1) in FC-5:
$ python25
Python 2.5c1 (r25c1:51305, Aug 18 2006, 11:45:01)
[GCC 4.1.1 20060525 (Red Hat 4.1.1-1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import code
>>> c = code.InteractiveConsole()
>>> c.interact()
Python 2.5c1 (r25c1:51305, Aug 18 2006, 11:45:01)
[GCC 4.1.1 20060525 (Red Hat 4.1.1-1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> import sys
>>> sys.stdout.close()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.5/code.py", line 234, in interact
    line = self.raw_input(prompt)
  File "/usr/lib/python2.5/code.py", line 277, in raw_input
    return raw_input(prompt)
ValueError: I/O operation on closed file
>>>

no crash. With python 2.4 I get the same crash observed in this thread.

-- 
José Abílio



More information about the IPython-dev mailing list