(original) (raw)

changeset: 91546:888fd1cdec6f branch: 3.4 parent: 91542:6fb1e2ce513a user: Benjamin Peterson benjamin@python.org date: Fri Jul 04 17:00:25 2014 -0700 files: Modules/_io/_iomodule.c description: properly decref the return value of close() diff -r 6fb1e2ce513a -r 888fd1cdec6f Modules/_io/_iomodule.c --- a/Modules/_io/_iomodule.c Fri Jul 04 22:47:46 2014 +0200 +++ b/Modules/_io/_iomodule.c Fri Jul 04 17:00:25 2014 -0700 @@ -465,11 +465,13 @@ error: if (result != NULL) { - PyObject *exc, *val, *tb; + PyObject *exc, *val, *tb, *close_result; PyErr_Fetch(&exc, &val, &tb); - if (_PyObject_CallMethodId(result, &PyId_close, NULL) != NULL) + close_result = _PyObject_CallMethodId(result, &PyId_close, NULL); + if (close_result != NULL) { + Py_DECREF(close_result); PyErr_Restore(exc, val, tb); - else { + } else { PyObject *exc2, *val2, *tb2; PyErr_Fetch(&exc2, &val2, &tb2); PyErr_NormalizeException(&exc, &val, &tb); /benjamin@python.org