summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2007-08-30 23:34:01 (GMT)
committerGuido van Rossum <guido@python.org>2007-08-30 23:34:01 (GMT)
commit150b7d7d02eca6970d792f3e6887f957a36b6ca2 (patch)
treee4758ebdfedcf276b9cfbeff048736e712fb9e22 /Modules
parentd2cf20eea2338a0369d4a5707adb01b201f7dfb2 (diff)
downloadcpython-150b7d7d02eca6970d792f3e6887f957a36b6ca2.zip
cpython-150b7d7d02eca6970d792f3e6887f957a36b6ca2.tar.gz
cpython-150b7d7d02eca6970d792f3e6887f957a36b6ca2.tar.bz2
Remove curses temp file consistently.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_cursesmodule.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/Modules/_cursesmodule.c b/Modules/_cursesmodule.c
index 659ebce..a1d7e2e 100644
--- a/Modules/_cursesmodule.c
+++ b/Modules/_cursesmodule.c
@@ -1299,11 +1299,13 @@ PyCursesWindow_PutWin(PyCursesWindowObject *self, PyObject *stream)
fp = fdopen(fd, "wb+");
if (fp == NULL) {
close(fd);
+ remove(fn);
return PyErr_SetFromErrnoWithFilename(PyExc_IOError, fn);
}
res = PyCursesCheckERR(putwin(self->win, fp), "putwin");
if (res == NULL) {
fclose(fp);
+ remove(fn);
return res;
}
fseek(fp, 0, 0);
@@ -1785,11 +1787,13 @@ PyCurses_GetWin(PyCursesWindowObject *self, PyObject *stream)
fp = fdopen(fd, "wb+");
if (fp == NULL) {
close(fd);
+ remove(fn);
return PyErr_SetFromErrnoWithFilename(PyExc_IOError, fn);
}
data = PyObject_CallMethod(stream, "read", "");
if (data == NULL) {
fclose(fp);
+ remove(fn);
return NULL;
}
if (!PyBytes_Check(data)) {
@@ -1798,6 +1802,7 @@ PyCurses_GetWin(PyCursesWindowObject *self, PyObject *stream)
data->ob_type->tp_name);
Py_DECREF(data);
fclose(fp);
+ remove(fn);
return NULL;
}
fwrite(PyBytes_AS_STRING(data), 1, PyBytes_GET_SIZE(data), fp);
@@ -1805,6 +1810,7 @@ PyCurses_GetWin(PyCursesWindowObject *self, PyObject *stream)
fseek(fp, 0, 0);
win = getwin(fp);
fclose(fp);
+ remove(fn);
if (win == NULL) {
PyErr_SetString(PyCursesError, catchall_NULL);
return NULL;