summaryrefslogtreecommitdiffstats
path: root/Modules/_io
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2015-03-30 08:09:31 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2015-03-30 08:09:31 (GMT)
commite134a7fe36652434c2ccffc4ebab2ec2031d1505 (patch)
tree9eea060bf19c856881f438860eb2abdbe41f2bdd /Modules/_io
parent2e1c4e5db2894ec4322f917e9babc4e37dca9244 (diff)
downloadcpython-e134a7fe36652434c2ccffc4ebab2ec2031d1505.zip
cpython-e134a7fe36652434c2ccffc4ebab2ec2031d1505.tar.gz
cpython-e134a7fe36652434c2ccffc4ebab2ec2031d1505.tar.bz2
Issue #23752: _Py_fstat() is now responsible to raise the Python exception
Add _Py_fstat_noraise() function when a Python exception is not welcome.
Diffstat (limited to 'Modules/_io')
-rw-r--r--Modules/_io/fileio.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/Modules/_io/fileio.c b/Modules/_io/fileio.c
index 595f99e..b56a9c3 100644
--- a/Modules/_io/fileio.c
+++ b/Modules/_io/fileio.c
@@ -399,10 +399,8 @@ fileio_init(PyObject *oself, PyObject *args, PyObject *kwds)
}
self->blksize = DEFAULT_BUFFER_SIZE;
- if (_Py_fstat(self->fd, &fdfstat) < 0) {
- PyErr_SetFromErrno(PyExc_OSError);
+ if (_Py_fstat(self->fd, &fdfstat) < 0)
goto error;
- }
#if defined(S_ISDIR) && defined(EISDIR)
/* On Unix, open will succeed for directories.
In Python, there should be no file objects referring to
@@ -589,7 +587,7 @@ new_buffersize(fileio *self, size_t currentsize)
static PyObject *
fileio_readall(fileio *self)
{
- struct _Py_stat_struct st;
+ struct _Py_stat_struct status;
Py_off_t pos, end;
PyObject *result;
Py_ssize_t bytes_read = 0;
@@ -606,8 +604,8 @@ fileio_readall(fileio *self)
#else
pos = lseek(self->fd, 0L, SEEK_CUR);
#endif
- if (_Py_fstat(self->fd, &st) == 0)
- end = st.st_size;
+ if (_Py_fstat_noraise(self->fd, &status) == 0)
+ end = status.st_size;
else
end = (Py_off_t)-1;