100 lines
2.6 KiB
Diff
100 lines
2.6 KiB
Diff
diff -Naur Python-3.5.0-orig/Modules/_cursesmodule.c Python-3.5.0/Modules/_cursesmodule.c
|
|
--- Python-3.5.0-orig/Modules/_cursesmodule.c 2015-09-13 14:41:24.000000000 +0300
|
|
+++ Python-3.5.0/Modules/_cursesmodule.c 2015-09-21 13:42:27.468380800 +0300
|
|
@@ -125,6 +125,10 @@
|
|
#include <langinfo.h>
|
|
#endif
|
|
|
|
+#ifdef __MINGW32__
|
|
+#include <windows.h>
|
|
+#endif
|
|
+
|
|
#if !defined(HAVE_NCURSES_H) && (defined(sgi) || defined(__sun) || defined(SCO5))
|
|
#define STRICT_SYSV_CURSES /* Don't use ncurses extensions */
|
|
typedef chtype attr_t; /* No attr_t type is available */
|
|
@@ -1709,10 +1713,14 @@
|
|
/* We have to simulate this by writing to a temporary FILE*,
|
|
then reading back, then writing to the argument stream. */
|
|
char fn[100];
|
|
+#ifndef MS_WINDOWS
|
|
int fd = -1;
|
|
+#endif
|
|
FILE *fp = NULL;
|
|
PyObject *res = NULL;
|
|
|
|
+#ifndef MS_WINDOWS
|
|
+/* Even on unix /tmp may not exist and the program must prefer $TMPDIR ! */
|
|
strcpy(fn, "/tmp/py.curses.putwin.XXXXXX");
|
|
fd = mkstemp(fn);
|
|
if (fd < 0)
|
|
@@ -1720,6 +1728,14 @@
|
|
if (_Py_set_inheritable(fd, 0, NULL) < 0)
|
|
goto exit;
|
|
fp = fdopen(fd, "wb+");
|
|
+#else
|
|
+ strcpy(fn, "py.curses.putwin.XXXXXX");
|
|
+ _mktemp(fn);
|
|
+ if (*fn == 0)
|
|
+ return PyErr_SetFromErrnoWithFilename(PyExc_IOError, fn);
|
|
+ fp = fopen(fn, "wb+");
|
|
+#endif
|
|
+
|
|
if (fp == NULL) {
|
|
PyErr_SetFromErrnoWithFilename(PyExc_IOError, fn);
|
|
goto exit;
|
|
@@ -1744,8 +1760,10 @@
|
|
exit:
|
|
if (fp != NULL)
|
|
fclose(fp);
|
|
+ #ifndef MS_WINDOWS
|
|
else if (fd != -1)
|
|
close(fd);
|
|
+ #endif
|
|
remove(fn);
|
|
return res;
|
|
}
|
|
@@ -2268,7 +2286,9 @@
|
|
PyCurses_GetWin(PyCursesWindowObject *self, PyObject *stream)
|
|
{
|
|
char fn[100];
|
|
+#ifndef MS_WINDOWS
|
|
int fd = -1;
|
|
+#endif
|
|
FILE *fp = NULL;
|
|
PyObject *data;
|
|
size_t datalen;
|
|
@@ -2278,6 +2298,8 @@
|
|
|
|
PyCursesInitialised;
|
|
|
|
+#ifndef MS_WINDOWS
|
|
+/* Even on unix /tmp may not exist and the program must prefer $TMPDIR ! */
|
|
strcpy(fn, "/tmp/py.curses.getwin.XXXXXX");
|
|
fd = mkstemp(fn);
|
|
if (fd < 0)
|
|
@@ -2285,6 +2307,13 @@
|
|
if (_Py_set_inheritable(fd, 0, NULL) < 0)
|
|
goto error;
|
|
fp = fdopen(fd, "wb+");
|
|
+#else
|
|
+ strcpy(fn, "py.curses.getwin.XXXXXX");
|
|
+ _mktemp(fn);
|
|
+ if (*fn == 0)
|
|
+ return PyErr_SetFromErrnoWithFilename(PyExc_IOError, fn);
|
|
+ fp = fopen(fn, "wb+");
|
|
+#endif
|
|
if (fp == NULL) {
|
|
PyErr_SetFromErrnoWithFilename(PyExc_IOError, fn);
|
|
goto error;
|
|
@@ -2319,8 +2348,10 @@
|
|
error:
|
|
if (fp != NULL)
|
|
fclose(fp);
|
|
+ #ifndef MS_WINDOWS
|
|
else if (fd != -1)
|
|
close(fd);
|
|
+ #endif
|
|
remove(fn);
|
|
return res;
|
|
}
|