mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Remove curses temp file consistently.
This commit is contained in:
parent
d2cf20eea2
commit
150b7d7d02
1 changed files with 6 additions and 0 deletions
|
@ -1299,11 +1299,13 @@ PyCursesWindow_PutWin(PyCursesWindowObject *self, PyObject *stream)
|
||||||
fp = fdopen(fd, "wb+");
|
fp = fdopen(fd, "wb+");
|
||||||
if (fp == NULL) {
|
if (fp == NULL) {
|
||||||
close(fd);
|
close(fd);
|
||||||
|
remove(fn);
|
||||||
return PyErr_SetFromErrnoWithFilename(PyExc_IOError, fn);
|
return PyErr_SetFromErrnoWithFilename(PyExc_IOError, fn);
|
||||||
}
|
}
|
||||||
res = PyCursesCheckERR(putwin(self->win, fp), "putwin");
|
res = PyCursesCheckERR(putwin(self->win, fp), "putwin");
|
||||||
if (res == NULL) {
|
if (res == NULL) {
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
remove(fn);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
fseek(fp, 0, 0);
|
fseek(fp, 0, 0);
|
||||||
|
@ -1785,11 +1787,13 @@ PyCurses_GetWin(PyCursesWindowObject *self, PyObject *stream)
|
||||||
fp = fdopen(fd, "wb+");
|
fp = fdopen(fd, "wb+");
|
||||||
if (fp == NULL) {
|
if (fp == NULL) {
|
||||||
close(fd);
|
close(fd);
|
||||||
|
remove(fn);
|
||||||
return PyErr_SetFromErrnoWithFilename(PyExc_IOError, fn);
|
return PyErr_SetFromErrnoWithFilename(PyExc_IOError, fn);
|
||||||
}
|
}
|
||||||
data = PyObject_CallMethod(stream, "read", "");
|
data = PyObject_CallMethod(stream, "read", "");
|
||||||
if (data == NULL) {
|
if (data == NULL) {
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
remove(fn);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (!PyBytes_Check(data)) {
|
if (!PyBytes_Check(data)) {
|
||||||
|
@ -1798,6 +1802,7 @@ PyCurses_GetWin(PyCursesWindowObject *self, PyObject *stream)
|
||||||
data->ob_type->tp_name);
|
data->ob_type->tp_name);
|
||||||
Py_DECREF(data);
|
Py_DECREF(data);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
remove(fn);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
fwrite(PyBytes_AS_STRING(data), 1, PyBytes_GET_SIZE(data), fp);
|
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);
|
fseek(fp, 0, 0);
|
||||||
win = getwin(fp);
|
win = getwin(fp);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
remove(fn);
|
||||||
if (win == NULL) {
|
if (win == NULL) {
|
||||||
PyErr_SetString(PyCursesError, catchall_NULL);
|
PyErr_SetString(PyCursesError, catchall_NULL);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue