summaryrefslogtreecommitdiffstats
path: root/Modules/_io/fileio.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2015-03-30 01:21:06 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2015-03-30 01:21:06 (GMT)
commit520bddf79a06c06d7b293408a6e3cc119f808afb (patch)
tree223cf7165bc91afaf09008f1b34f927e7637e22b /Modules/_io/fileio.c
parentedddf991d9ea88d16c8ebef7a5f829822d8025fa (diff)
downloadcpython-520bddf79a06c06d7b293408a6e3cc119f808afb.zip
cpython-520bddf79a06c06d7b293408a6e3cc119f808afb.tar.gz
cpython-520bddf79a06c06d7b293408a6e3cc119f808afb.tar.bz2
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.
Diffstat (limited to 'Modules/_io/fileio.c')
-rw-r--r--Modules/_io/fileio.c24
1 files changed, 0 insertions, 24 deletions
diff --git a/Modules/_io/fileio.c b/Modules/_io/fileio.c
index b35a51b..595f99e 100644
--- a/Modules/_io/fileio.c
+++ b/Modules/_io/fileio.c
@@ -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;
}