Fixed incompatibilities with os module.
- os.fdopen should raise OSError, not IOError.
This commit is contained in:
@@ -18,7 +18,10 @@ def fdopen(fd, *args, **kw):
|
||||
Return an open file object connected to a file descriptor."""
|
||||
if not isinstance(fd, int):
|
||||
raise TypeError('fd should be int, not %r' % fd)
|
||||
return greenio.GreenPipe(fd, *args, **kw)
|
||||
try:
|
||||
return greenio.GreenPipe(fd, *args, **kw)
|
||||
except IOError, e:
|
||||
raise OSError(*e.args)
|
||||
|
||||
__original_read__ = os_orig.read
|
||||
def read(fd, n):
|
||||
|
@@ -347,7 +347,11 @@ class _SocketDuckForFd(object):
|
||||
raise IOError(*e.args)
|
||||
|
||||
def __del__(self):
|
||||
os.close(self._fileno)
|
||||
try:
|
||||
os.close(self._fileno)
|
||||
except:
|
||||
# os.close may fail if __init__ didn't complete (i.e file dscriptor passed to popen was invalid
|
||||
pass
|
||||
|
||||
def __repr__(self):
|
||||
return "%s:%d" % (self.__class__.__name__, self._fileno)
|
||||
|
Reference in New Issue
Block a user