]> granicus.if.org Git - python/commitdiff
Issue #23752: When built from an existing file descriptor, io.FileIO() now only
authorVictor Stinner <victor.stinner@gmail.com>
Mon, 30 Mar 2015 01:21:06 +0000 (03:21 +0200)
committerVictor Stinner <victor.stinner@gmail.com>
Mon, 30 Mar 2015 01:21:06 +0000 (03:21 +0200)
calls fstat() once. Before fstat() was called twice, which was not necessary.

Misc/NEWS
Modules/_io/fileio.c

index e96d66e0ac0ae3b4ab75647497073a9b2c580867..2b9ce2e7443e11a7847095acdba9d84373fc4c42 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -2,6 +2,32 @@
 Python News
 +++++++++++
 
+What's New in Python 3.5.0 alpha 4?
+===================================
+
+Release date: XXX
+
+Core and Builtins
+-----------------
+
+Library
+-------
+
+- Issue #23752: When built from an existing file descriptor, io.FileIO() now
+  only calls fstat() once. Before fstat() was called twice, which was not
+  necessary.
+
+Build
+-----
+
+Tests
+-----
+
+Tools/Demos
+-----------
+
+
+
 What's New in Python 3.5.0 alpha 3?
 ===================================
 
index b35a51b4e1afece34f1f93df85c788281bc4308e..595f99ee858a001b4e6f74b7e8cf71cb0dbe4266 100644 (file)
@@ -177,28 +177,6 @@ fileio_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
     return (PyObject *) self;
 }
 
-static int
-check_fd(int fd)
-{
-    struct _Py_stat_struct buf;
-    if (_Py_fstat(fd, &buf) < 0 &&
-#ifdef MS_WINDOWS
-        GetLastError() == ERROR_INVALID_HANDLE
-#else
-        errno == EBADF
-#endif
-        ) {
-        PyObject *exc;
-        char *msg = strerror(EBADF);
-        exc = PyObject_CallFunction(PyExc_OSError, "(is)",
-                                    EBADF, msg);
-        PyErr_SetObject(PyExc_OSError, exc);
-        Py_XDECREF(exc);
-        return -1;
-    }
-    return 0;
-}
-
 #ifdef O_CLOEXEC
 extern int _Py_open_cloexec_works;
 #endif
@@ -355,8 +333,6 @@ fileio_init(PyObject *oself, PyObject *args, PyObject *kwds)
 #endif
 
     if (fd >= 0) {
-        if (check_fd(fd))
-            goto error;
         self->fd = fd;
         self->closefd = closefd;
     }