summaryrefslogtreecommitdiffstats
path: root/Modules/_io
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2013-11-07 23:29:41 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2013-11-07 23:29:41 (GMT)
commitaa5bbfaa77a14634a035233a8879351d320bad6c (patch)
treeb63057d9185eaa805656bf822e2c583f94254075 /Modules/_io
parent50abf2294ed5623e9b8025c5ed8e143f2f4af75c (diff)
downloadcpython-aa5bbfaa77a14634a035233a8879351d320bad6c.zip
cpython-aa5bbfaa77a14634a035233a8879351d320bad6c.tar.gz
cpython-aa5bbfaa77a14634a035233a8879351d320bad6c.tar.bz2
Issue #19437: Fix _io._IOBase.close(), handle _PyObject_SetAttrId() failure
Diffstat (limited to 'Modules/_io')
-rw-r--r--Modules/_io/iobase.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/Modules/_io/iobase.c b/Modules/_io/iobase.c
index b58687e..3da7e5d 100644
--- a/Modules/_io/iobase.c
+++ b/Modules/_io/iobase.c
@@ -186,11 +186,16 @@ iobase_close(PyObject *self, PyObject *args)
Py_RETURN_NONE;
res = PyObject_CallMethodObjArgs(self, _PyIO_str_flush, NULL);
- _PyObject_SetAttrId(self, &PyId___IOBase_closed, Py_True);
- if (res == NULL) {
+
+ if (_PyObject_SetAttrId(self, &PyId___IOBase_closed, Py_True) < 0) {
+ Py_XDECREF(res);
return NULL;
}
- Py_XDECREF(res);
+
+ if (res == NULL)
+ return NULL;
+
+ Py_DECREF(res);
Py_RETURN_NONE;
}