diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2015-03-24 21:21:57 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2015-03-24 21:21:57 (GMT) |
commit | 7665be6087d879a96c4238684b2dfc642c67e60c (patch) | |
tree | e0b51ca3e484cd4717ed04857935a018234a3d9b /Modules/_io | |
parent | 8ffe917cee26b83fed4f227c4ed16d4eec15dcf9 (diff) | |
download | cpython-7665be6087d879a96c4238684b2dfc642c67e60c.zip cpython-7665be6087d879a96c4238684b2dfc642c67e60c.tar.gz cpython-7665be6087d879a96c4238684b2dfc642c67e60c.tar.bz2 |
Issue #21802: The reader in BufferedRWPair now is closed even when closing
writer failed in BufferedRWPair.close().
Diffstat (limited to 'Modules/_io')
-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 02cf038..445c870 100644 --- a/Modules/_io/bufferedio.c +++ b/Modules/_io/bufferedio.c @@ -2365,12 +2365,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 * |