Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 520bddf

Browse files
committed
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.
1 parent edddf99 commit 520bddf

2 files changed

Lines changed: 26 additions & 24 deletions

File tree

Misc/NEWS

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,32 @@
22
Python News
33
+++++++++++
44

5+
What's New in Python 3.5.0 alpha 4?
6+
===================================
7+
8+
Release date: XXX
9+
10+
Core and Builtins
11+
-----------------
12+
13+
Library
14+
-------
15+
16+
- Issue #23752: When built from an existing file descriptor, io.FileIO() now
17+
only calls fstat() once. Before fstat() was called twice, which was not
18+
necessary.
19+
20+
Build
21+
-----
22+
23+
Tests
24+
-----
25+
26+
Tools/Demos
27+
-----------
28+
29+
30+
531
What's New in Python 3.5.0 alpha 3?
632
===================================
733

Modules/_io/fileio.c

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -177,28 +177,6 @@ fileio_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
177177
return (PyObject *) self;
178178
}
179179

180-
static int
181-
check_fd(int fd)
182-
{
183-
struct _Py_stat_struct buf;
184-
if (_Py_fstat(fd, &buf) < 0 &&
185-
#ifdef MS_WINDOWS
186-
GetLastError() == ERROR_INVALID_HANDLE
187-
#else
188-
errno == EBADF
189-
#endif
190-
) {
191-
PyObject *exc;
192-
char *msg = strerror(EBADF);
193-
exc = PyObject_CallFunction(PyExc_OSError, "(is)",
194-
EBADF, msg);
195-
PyErr_SetObject(PyExc_OSError, exc);
196-
Py_XDECREF(exc);
197-
return -1;
198-
}
199-
return 0;
200-
}
201-
202180
#ifdef O_CLOEXEC
203181
extern int _Py_open_cloexec_works;
204182
#endif
@@ -355,8 +333,6 @@ fileio_init(PyObject *oself, PyObject *args, PyObject *kwds)
355333
#endif
356334

357335
if (fd >= 0) {
358-
if (check_fd(fd))
359-
goto error;
360336
self->fd = fd;
361337
self->closefd = closefd;
362338
}

0 commit comments

Comments
 (0)