]> granicus.if.org Git - vim/commitdiff
patch 8.2.1806: MS-Windows with Python: Vim freezes after import command v8.2.1806
authorBram Moolenaar <Bram@vim.org>
Tue, 6 Oct 2020 17:59:06 +0000 (19:59 +0200)
committerBram Moolenaar <Bram@vim.org>
Tue, 6 Oct 2020 17:59:06 +0000 (19:59 +0200)
Problem:    MS-Windows with Python: Vim freezes after import command.
Solution:   Use either "NUL" or "CONIN$" when reopening stdin. (Yasuhiro
            Matsumoto, closes #7083)

src/if_python3.c
src/version.c

index 15c1d9973e862f112332d696c6345e9d0af8b093..f6904c38014ba66bb18106f4dd592b4d62803fc6 100644 (file)
@@ -917,6 +917,7 @@ reset_stdin(void)
 {
     FILE *(*py__acrt_iob_func)(unsigned) = NULL;
     FILE *(*pyfreopen)(const char *, const char *, FILE *) = NULL;
+    char *stdin_name = "NUL";
     HINSTANCE hinst;
 
 # ifdef DYNAMIC_PYTHON3
@@ -933,16 +934,18 @@ reset_stdin(void)
     if (py__acrt_iob_func)
     {
        HINSTANCE hpystdiodll = find_imported_module_by_funcname(hinst,
-                                                       "__acrt_iob_func");
+                                                           "__acrt_iob_func");
        if (hpystdiodll)
-           pyfreopen = (void*)GetProcAddress(hpystdiodll, "freopen");
+           pyfreopen = (void *)GetProcAddress(hpystdiodll, "freopen");
     }
+    if (isatty(fileno(stdin)))
+       stdin_name = "CONIN$";
 
-    // Reconnect stdin to NUL.
-    if (pyfreopen)
-       pyfreopen("NUL", "r", py__acrt_iob_func(0));
+    // Reconnect stdin to NUL or CONIN$.
+    if (pyfreopen != NULL)
+       pyfreopen(stdin_name, "r", py__acrt_iob_func(0));
     else
-       freopen("NUL", "r", stdin);
+       freopen(stdin_name, "r", stdin);
 }
 #else
 # define reset_stdin()
index b8b9917d069b1de47370d37cec195fc674fa6952..a410167bebc92813a748c1eb86841d6d369f4d2d 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1806,
 /**/
     1805,
 /**/