New submission from Nir Soffer:

The docs (http://docs.python.org/dev/3.0/library/stdtypes.html#sequence-
types-str-bytes-list-tuple-buffer-range) warn that .fileno and .istty 
should not be implemented by a file like object.

This require client to check if the file object has the attribute before 
they call the method, instead of treating all files the same.

    if hasattr(foo, 'istty'):
        if foo.istty():
            # ...

Instead of:

    if foo.istty():
        # ...

istty can easily return False. fileno can return invalid file descriptor 
number (-1?).

----------
components: Library (Lib)
messages: 55724
nosy: nirs
severity: normal
status: open
title: file.fileno and file.isatty() should be implementable by any file like 
object
type: rfe
versions: Python 3.0

__________________________________
Tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue1126>
__________________________________
_______________________________________________
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to