[vim/vim] Vim freezes after python import command (#7083)

37 views
Skip to first unread message

zakutin

unread,
Oct 5, 2020, 9:11:55 AM10/5/20
to vim/vim, Subscribed

Describe the bug
After the installation of jedi-vim, vim freezes in Windows Terminal or powershell on python file opening, so that I need to terminate the process, because vim does not accept any commands. However, jedi-vim works well in gVim.

I researched a little bit, there is something to do with :python3 import or python installation in general. I tried to disable all vim modules and execute :python3 import sys; print(sys.version) – the vim got frozen and doesn't react on any keys, though the cursor is blinking.

I reinstalled python and vim again, checked environment variables, but the issue with python import still persists.
In gVim :python3 import sys; print(sys.version) executes fine.

To Reproduce
Detailed steps to reproduce the behavior:

  1. run vim in Windows Terminal or in Powershell
  2. execute :python3 import sys
  3. vim hangs without any error message, no reaction on keys, cursor is blinking

Expected behavior
Vim shall not freeze on python import command.

Screenshots
N/A

Environment (please complete the following information):
Windows 10 Pro x64 2004
PowerShell 7.0.3
Windows Terminal 1.3.2651.0
Vim version 8.2.1801
Python 3.8.5/3.8.6 x64

Additional context
N/A


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.

mattn

unread,
Oct 5, 2020, 10:13:35 AM10/5/20
to vim/vim, Subscribed

Probably related issue #6641 #7053 #7061

zakutin

unread,
Oct 5, 2020, 12:17:43 PM10/5/20
to vim/vim, Subscribed

Thank you @mattn , I scrolled through the links you gave, however, it was a bit complicated for me to interpret the content properly. Is it already fixed or still in process? Is there any workaround?

IanSmith21

unread,
Oct 5, 2020, 7:25:14 PM10/5/20
to vim/vim, Subscribed

I have the same issue. Also looking for a workaround or fix.

K.Takata

unread,
Oct 5, 2020, 7:28:57 PM10/5/20
to vim/vim, Subscribed

Please use 8.2.1789 or earlier for a while. We are preparing a fix.

IanSmith21

unread,
Oct 5, 2020, 7:34:33 PM10/5/20
to vim/vim, Subscribed

Using https://chocolatey.org/packages/vim/8.2.1787 without issue now! Thank you for the quick response.

mattn

unread,
Oct 5, 2020, 7:58:46 PM10/5/20
to vim/vim, Subscribed

K.Takata

unread,
Oct 6, 2020, 6:43:25 AM10/6/20
to vim/vim, Subscribed

Thank you, @mattn.
I confirmed that your patch worked fine (also with Vifm).
I hope a few more people try this.

BTW, maybe the comments (two parts) should be updated. E.g. "Reconnect stdin to CONIN$ or NUL."

IanSmith21

unread,
Oct 6, 2020, 12:28:40 PM10/6/20
to vim/vim, Subscribed

Verified that it worked too. @mattn Thank you.

Bram Moolenaar

unread,
Oct 6, 2020, 2:00:09 PM10/6/20
to vim/vim, Subscribed

Closed #7083 via 253b16a.

xaizek

unread,
Oct 10, 2020, 10:11:09 AM10/10/20
to vim/vim, Subscribed

Fix for this issue broke #7053 again, so I played with a simple isatty-program as the one on this MSDN page. When I do a.exe < NUL, redirection isn't detected. It's Windows we're dealing with here...

This, however, seems to detect redirection (can't query console mode of something other than the console):

diff --git a/src/if_python3.c b/src/if_python3.c
index f6904c380..cf681377e 100644
--- a/src/if_python3.c
+++ b/src/if_python3.c
@@ -938,7 +938,9 @@ reset_stdin(void)
 	if (hpystdiodll)
 	    pyfreopen = (void *)GetProcAddress(hpystdiodll, "freopen");
     }
-    if (isatty(fileno(stdin)))
+
+    DWORD ignored_mode;
+    if (GetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), &ignored_mode))
 	stdin_name = "CONIN$";
 
     // Reconnect stdin to NUL or CONIN$.

I can't reproduce #7083 (this issue) on Windows 7 (no hang), but it does fix #7053. Can someone confirm that it doesn't break anything?

zakutin

unread,
Oct 14, 2020, 6:40:33 AM10/14/20
to vim/vim, Subscribed

Please use 8.2.1789 or earlier for a while. We are preparing a fix.

This version freezes as well. Strange behavior noticed:

  • :python3 import sys; print(sys.version) executes well without freezing
  • any python file created, edited and saved
  • the python file is executed in the same terminal
  • the python file reopened with vim
  • vim is frozen, cpu load 25%
  • kill vim, reopen python file with vim again -- everything works.

OR

repeatedly open/save/close/reopen the python file causes vim to freeze occasionally.

K.Takata

unread,
Oct 14, 2020, 6:45:52 AM10/14/20
to vim/vim, Subscribed

Please try 8.2.1830 or later.
From 8.2.1381 to 8.2.1829 have some issues with python 3.

IanSmith21

unread,
Oct 14, 2020, 12:36:18 PM10/14/20
to vim/vim, Subscribed

@k-takata I have been using 8.2.184 for a few days and I have not been able to reproduce the issue.

K.Takata

unread,
Oct 14, 2020, 7:28:19 PM10/14/20
to vim/vim, Subscribed

Are you talking about 8.2.1840?

IanSmith21

unread,
Oct 14, 2020, 7:30:19 PM10/14/20
to vim/vim, Subscribed

Yes. Sorry. 184->1840

I have been using 8.2.1840 for a few days and I have not been able to reproduce the issue.

Maxim Kim

unread,
Oct 15, 2020, 2:24:23 AM10/15/20
to vim_dev
I had the same issue with YCM which uses python too: https://github.com/ycm-core/YouCompleteMe/issues/3772

Tried with 8.2.1840 -- no issues so far.


четверг, 15 октября 2020 г. в 02:30:19 UTC+3, IanSmith21:
Reply all
Reply to author
Forward
0 new messages