Commits

mattip  committed c0342ec

Backed out changeset: af45af09d486

  • Participants
  • Parent commits ff8855b

Comments (0)

Files changed (3)

File pypy/module/__pypy__/interp_magic.py

 @unwrap_spec(fd='c_int')
 def validate_fd(space, fd):
     try:
-        rposix._validate_fd(fd)
+        rposix.validate_fd(fd)
     except OSError, e:
         raise wrap_oserror(space, e)

File pypy/module/posix/app_posix.py

         if self.st_ctime is None:
             self.__dict__['st_ctime'] = self[9]
 
+if osname == 'posix':
+    def _validate_fd(fd):
+        try:
+            import fcntl
+        except ImportError:
+            return
+        try:
+            fcntl.fcntl(fd, fcntl.F_GETFD)
+        except IOError, e:
+            raise OSError(e.errno, e.strerror, e.filename)
+else:
+    _validate_fd = validate_fd
 
 # Capture file.fdopen at import time, as some code replaces
 # __builtins__.file with a custom function.
     """fdopen(fd [, mode='r' [, buffering]]) -> file_object
 
     Return an open file object connected to a file descriptor."""
-    validate_fd(fd)
+    _validate_fd(fd)
     return _fdopen(fd, mode, buffering)
 
 

File pypy/rlib/rposix.py

     def validate_fd(fd):
         if not is_valid_fd(fd):
             raise OSError(get_errno(), 'Bad file descriptor')
-    _validate_fd = validate_fd    
 else:
     def is_valid_fd(fd):
         return 1
-    # CPython for linux only validates in the posix module.
-    # in the os module, validate_fd is a nop.
+
     def validate_fd(fd):
         return 1
-    def _validate_fd(fd):
-        try:
-            import fcntl
-        except ImportError:
-            return
-        try:
-            fcntl.fcntl(fd, fcntl.F_GETFD)
-        except IOError, e:
-            raise OSError(e.errno, e.strerror, e.filename)
 
 def closerange(fd_low, fd_high):
     # this behaves like os.closerange() from Python 2.6.