diff -r b57c44655fea Modules/_io/fileio.c --- a/Modules/_io/fileio.c Mon Mar 23 21:21:00 2015 +0100 +++ b/Modules/_io/fileio.c Mon Mar 23 21:45:17 2015 +0100 @@ -177,30 +177,6 @@ fileio_new(PyTypeObject *type, PyObject return (PyObject *) self; } -static int -check_fd(int fd) -{ -#if defined(HAVE_FSTAT) || defined(MS_WINDOWS) - 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; - } -#endif - return 0; -} - #ifdef O_CLOEXEC extern int _Py_open_cloexec_works; #endif @@ -359,8 +335,6 @@ fileio_init(PyObject *oself, PyObject *a #endif if (fd >= 0) { - if (check_fd(fd)) - goto error; self->fd = fd; self->closefd = closefd; }