[Python-Dev] isatty() on closed StringIO

Walter Dörwald walter at livinglogic.de
Fri Nov 18 17:51:51 CET 2005


Paul Svensson wrote:

> On Fri, 18 Nov 2005, Walter Dörwald wrote:
> 
>> BTW, isatty() has a similar problem:
>>
>> >>> import StringIO, cStringIO
>> >>> s = StringIO.StringIO()
>> >>> s.close()
>> >>> s.isatty()
>> Traceback (most recent call last):
>>   File "<stdin>", line 1, in ?
>>   File "/usr/local/lib/python2.4/StringIO.py", line 93, in isatty
>>     _complain_ifclosed(self.closed)
>>   File "/usr/local/lib/python2.4/StringIO.py", line 40, in
>> _complain_ifclosed
>>     raise ValueError, "I/O operation on closed file"
>> ValueError: I/O operation on closed file
>> >>> s = cStringIO.StringIO()
>> >>> s.close()
>> >>> s.isatty()
>> False
>>
>> I guess cStringIO.StringIO.isatty() should raise an exception too.
> 
> 
> Why ?  Is there any doubt that it's not a tty ?

No, but for real files a ValueError is raised too.

Bye,
    Walter Dörwald


More information about the Python-Dev mailing list