Message89198
Worth noting is that Python documentation in:
http://docs.python.org/library/stdtypes.html
says:
"""
file.fileno()
Return the integer “file descriptor” that is used by the underlying
implementation to request I/O operations from the operating system. This
can be useful for other, lower level interfaces that use file
descriptors, such as the fcntl module or os.read() and friends.
Note File-like objects which do not have a real file descriptor should
not provide this method!
"""
So, if sys.stdin is replaced with a file like object, then the code
should not be assuming that fileno() even exists.
At the moment the code doesn't check for AttributeError which is what is
going to be raised for trying to access non existent fileno() method.
"""
>>> import StringIO
>>> s=StringIO.StringIO("xxx")
>>> s.fileno()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: StringIO instance has no attribute 'fileno'
"""
Thus error propagates. The better check though would be to use:
def _bootstrap(self):
....
if sys.stdin is not None and hasattr(sys.stdin, "fileno"):
try:
os.close(sys.stdin.fileno())
except (OSError, ValueError):
pass
That is, only actually call fileno() if it is present.
This would solve the problem for the original reported issue by making
it actually adhere to what Python documentation says about existence of
fileno().
This change wouldn't necessarily solve other peoples related issues
though. |
|
Date |
User |
Action |
Args |
2009-06-10 11:39:22 | grahamd | set | recipients:
+ grahamd, OG7, jnoller, i000 |
2009-06-10 11:39:22 | grahamd | set | messageid: <1244633962.33.0.273396204789.issue5313@psf.upfronthosting.co.za> |
2009-06-10 11:39:21 | grahamd | link | issue5313 messages |
2009-06-10 11:39:20 | grahamd | create | |
|