Mercurial > vim
changeset 22516:c174ec901f7e v8.2.1806
patch 8.2.1806: MS-Windows with Python: Vim freezes after import command
Commit: https://github.com/vim/vim/commit/253b16a4abdad1df350b9ddd9a709520b063934c
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Oct 6 19:59:06 2020 +0200
patch 8.2.1806: MS-Windows with Python: Vim freezes after import command
Problem: MS-Windows with Python: Vim freezes after import command.
Solution: Use either "NUL" or "CONIN$" when reopening stdin. (Yasuhiro
Matsumoto, closes #7083)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 06 Oct 2020 20:00:04 +0200 |
parents | db179e02143d |
children | 6acf73cc1863 |
files | src/if_python3.c src/version.c |
diffstat | 2 files changed, 11 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/src/if_python3.c +++ b/src/if_python3.c @@ -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()