diff options
| author | Benjamin Peterson <benjamin@python.org> | 2012-12-20 17:55:16 (GMT) |
|---|---|---|
| committer | Benjamin Peterson <benjamin@python.org> | 2012-12-20 17:55:16 (GMT) |
| commit | 4c05969fc41d83e7da9ee3a2e15285a60b68ce23 (patch) | |
| tree | c8a4ea23a1f982f788d8b1619d218b009091f3c9 /Modules/_io/bufferedio.c | |
| parent | 7643c92cdd0e8a3cfd83be9edae3964097b63f0e (diff) | |
| parent | 68623614f095c8589ff17c004b9a05c537afc01f (diff) | |
| download | cpython-4c05969fc41d83e7da9ee3a2e15285a60b68ce23.zip cpython-4c05969fc41d83e7da9ee3a2e15285a60b68ce23.tar.gz cpython-4c05969fc41d83e7da9ee3a2e15285a60b68ce23.tar.bz2 | |
merge 3.3 (#16597)
Diffstat (limited to 'Modules/_io/bufferedio.c')
| -rw-r--r-- | Modules/_io/bufferedio.c | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/Modules/_io/bufferedio.c b/Modules/_io/bufferedio.c index 432349a..ea32a5e 100644 --- a/Modules/_io/bufferedio.c +++ b/Modules/_io/bufferedio.c @@ -484,7 +484,7 @@ buffered_closed_get(buffered *self, void *context) static PyObject * buffered_close(buffered *self, PyObject *args) { - PyObject *res = NULL; + PyObject *res = NULL, *exc = NULL, *val, *tb; int r; CHECK_INITIALIZED(self) @@ -512,10 +512,10 @@ buffered_close(buffered *self, PyObject *args) res = PyObject_CallMethodObjArgs((PyObject *)self, _PyIO_str_flush, NULL); if (!ENTER_BUFFERED(self)) return NULL; - if (res == NULL) { - goto end; - } - Py_XDECREF(res); + if (res == NULL) + PyErr_Fetch(&exc, &val, &tb); + else + Py_DECREF(res); res = PyObject_CallMethodObjArgs(self->raw, _PyIO_str_close, NULL); @@ -524,6 +524,22 @@ buffered_close(buffered *self, PyObject *args) self->buffer = NULL; } + if (exc != NULL) { + if (res != NULL) { + Py_CLEAR(res); + PyErr_Restore(exc, val, tb); + } + else { + PyObject *val2; + Py_DECREF(exc); + Py_XDECREF(tb); + PyErr_Fetch(&exc, &val2, &tb); + PyErr_NormalizeException(&exc, &val2, &tb); + PyException_SetContext(val2, val); + PyErr_Restore(exc, val2, tb); + } + } + end: LEAVE_BUFFERED(self) return res; |
