[pypy-commit] pypy default: Remove an "import fcntl".

arigo noreply at buildbot.pypy.org
Sun Jun 10 22:40:53 CEST 2012


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r55553:e7676f485cb1
Date: 2012-06-10 22:40 +0200
http://bitbucket.org/pypy/pypy/changeset/e7676f485cb1/

Log:	Remove an "import fcntl".

diff --git a/pypy/module/posix/app_posix.py b/pypy/module/posix/app_posix.py
--- a/pypy/module/posix/app_posix.py
+++ b/pypy/module/posix/app_posix.py
@@ -66,15 +66,10 @@
             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)
+    # POSIX: we want to check the file descriptor when fdopen() is called,
+    # not later when we read or write data.  So we call fstat(), letting
+    # it raise if fd is invalid.
+    _validate_fd = posix.fstat
 else:
     _validate_fd = validate_fd
 


More information about the pypy-commit mailing list