summaryrefslogtreecommitdiff
path: root/Modules/_io/fileio.c
diff options
context:
space:
mode:
authorLarry Hastings <larry@hastings.org>2015-02-26 05:58:48 -0800
committerLarry Hastings <larry@hastings.org>2015-02-26 05:58:48 -0800
commit8c3ec536e924002dc3afe4ff92e32fe9ed82ebab (patch)
treef141eec287584ba9d58d32461e1a7d92b5466e91 /Modules/_io/fileio.c
parente287746401398ee81c8e8a1513a5fe828eb32559 (diff)
parent7b2c3c6840052ea6f8b41253faf38b9e24f9a453 (diff)
downloadcpython-git-8c3ec536e924002dc3afe4ff92e32fe9ed82ebab.tar.gz
Merge 3.4.3 release engineering changes back into 3.4.
Diffstat (limited to 'Modules/_io/fileio.c')
-rw-r--r--Modules/_io/fileio.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/Modules/_io/fileio.c b/Modules/_io/fileio.c
index a2b253bd03..80ca99c5bc 100644
--- a/Modules/_io/fileio.c
+++ b/Modules/_io/fileio.c
@@ -126,11 +126,18 @@ internal_close(fileio *self)
static PyObject *
fileio_close(fileio *self)
{
+ PyObject *res;
+ PyObject *exc, *val, *tb;
+ int rc;
_Py_IDENTIFIER(close);
+ res = _PyObject_CallMethodId((PyObject*)&PyRawIOBase_Type,
+ &PyId_close, "O", self);
if (!self->closefd) {
self->fd = -1;
- Py_RETURN_NONE;
+ return res;
}
+ if (res == NULL)
+ PyErr_Fetch(&exc, &val, &tb);
if (self->finalizing) {
PyObject *r = fileio_dealloc_warn(self, (PyObject *) self);
if (r)
@@ -138,12 +145,12 @@ fileio_close(fileio *self)
else
PyErr_Clear();
}
- errno = internal_close(self);
- if (errno < 0)
- return NULL;
-
- return _PyObject_CallMethodId((PyObject*)&PyRawIOBase_Type,
- &PyId_close, "O", self);
+ rc = internal_close(self);
+ if (res == NULL)
+ _PyErr_ChainExceptions(exc, val, tb);
+ if (rc < 0)
+ Py_CLEAR(res);
+ return res;
}
static PyObject *