Commits

Anonymous committed 9b9c516

Fixed incompatibilities with os module.
- os.fdopen should raise OSError, not IOError.

  • Participants
  • Parent commits ff64582

Comments (0)

Files changed (2)

eventlet/green/os.py

     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):

eventlet/greenio.py

                     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)