diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2015-03-24 21:23:28 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2015-03-24 21:23:28 (GMT) |
commit | 8be6be427d7af54cd2dcc5f7c8f73ec2a1e2dfcc (patch) | |
tree | 8ad1b6881ee6f462f15143f863c09243fc199888 /Modules/_io/bufferedio.c | |
parent | a54aae068325551bcc70c151b483f1b38ca0c687 (diff) | |
parent | 7665be6087d879a96c4238684b2dfc642c67e60c (diff) | |
download | cpython-8be6be427d7af54cd2dcc5f7c8f73ec2a1e2dfcc.zip cpython-8be6be427d7af54cd2dcc5f7c8f73ec2a1e2dfcc.tar.gz cpython-8be6be427d7af54cd2dcc5f7c8f73ec2a1e2dfcc.tar.bz2 |
Issue #21802: The reader in BufferedRWPair now is closed even when closing
writer failed in BufferedRWPair.close().
Diffstat (limited to 'Modules/_io/bufferedio.c')
-rw-r--r-- | Modules/_io/bufferedio.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/Modules/_io/bufferedio.c b/Modules/_io/bufferedio.c index 358a94d..ea9f533 100644 --- a/Modules/_io/bufferedio.c +++ b/Modules/_io/bufferedio.c @@ -2413,12 +2413,18 @@ bufferedrwpair_writable(rwpair *self, PyObject *args) static PyObject * bufferedrwpair_close(rwpair *self, PyObject *args) { + PyObject *exc = NULL, *val, *tb; PyObject *ret = _forward_call(self->writer, &PyId_close, args); if (ret == NULL) - return NULL; - Py_DECREF(ret); - - return _forward_call(self->reader, &PyId_close, args); + PyErr_Fetch(&exc, &val, &tb); + else + Py_DECREF(ret); + ret = _forward_call(self->reader, &PyId_close, args); + if (exc != NULL) { + _PyErr_ChainExceptions(exc, val, tb); + Py_CLEAR(ret); + } + return ret; } static PyObject * |