Skip to content

Commit

Permalink
patch 8.2.1806: MS-Windows with Python: Vim freezes after import command
Browse files Browse the repository at this point in the history
Problem:    MS-Windows with Python: Vim freezes after import command.
Solution:   Use either "NUL" or "CONIN$" when reopening stdin. (Yasuhiro
            Matsumoto, closes vim#7083)
  • Loading branch information
brammool committed Oct 6, 2020
1 parent 80361a5 commit 253b16a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/if_python3.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
1806,
/**/
1805,
/**/
Expand Down

0 comments on commit 253b16a

Please sign in to comment.