Mercurial > vim
comparison src/if_python3.c @ 22484:93f3cdc296e7 v8.2.1790
patch 8.2.1790: MS-Windows with Python: crash when executed from Vifm
Commit: https://github.com/vim/vim/commit/794771cfd83af2a0d1926bed301e784447e7290b
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Oct 3 13:57:13 2020 +0200
patch 8.2.1790: MS-Windows with Python: crash when executed from Vifm
Problem: MS-Windows with Python: crash when executed from Vifm.
Solution: Use NUL instead of CONIN. (Ken Takata, closes https://github.com/vim/vim/issues/7061, closes https://github.com/vim/vim/issues/7053)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 03 Oct 2020 14:00:04 +0200 |
parents | 21304d9c47e9 |
children | c174ec901f7e |
comparison
equal
deleted
inserted
replaced
22483:9bbe172e1c44 | 22484:93f3cdc296e7 |
---|---|
907 | 907 |
908 static wchar_t *py_home_buf = NULL; | 908 static wchar_t *py_home_buf = NULL; |
909 | 909 |
910 #if defined(MSWIN) && (PY_VERSION_HEX >= 0x030500f0) | 910 #if defined(MSWIN) && (PY_VERSION_HEX >= 0x030500f0) |
911 // Python 3.5 or later will abort inside Py_Initialize() when stdin is | 911 // Python 3.5 or later will abort inside Py_Initialize() when stdin is |
912 // redirected. Reconnect stdin to CONIN$. | 912 // redirected. Reconnect stdin to NUL. |
913 // Note that the python DLL is linked to its own stdio DLL which can be | 913 // Note that the python DLL is linked to its own stdio DLL which can be |
914 // differ from Vim's stdio. | 914 // differ from Vim's stdio. |
915 static void | 915 static void |
916 reset_stdin(void) | 916 reset_stdin(void) |
917 { | 917 { |
936 "__acrt_iob_func"); | 936 "__acrt_iob_func"); |
937 if (hpystdiodll) | 937 if (hpystdiodll) |
938 pyfreopen = (void*)GetProcAddress(hpystdiodll, "freopen"); | 938 pyfreopen = (void*)GetProcAddress(hpystdiodll, "freopen"); |
939 } | 939 } |
940 | 940 |
941 // Reconnect stdin to CONIN$. | 941 // Reconnect stdin to NUL. |
942 if (pyfreopen) | 942 if (pyfreopen) |
943 pyfreopen("CONIN$", "r", py__acrt_iob_func(0)); | 943 pyfreopen("NUL", "r", py__acrt_iob_func(0)); |
944 else | 944 else |
945 freopen("CONIN$", "r", stdin); | 945 freopen("NUL", "r", stdin); |
946 } | 946 } |
947 #else | 947 #else |
948 # define reset_stdin() | 948 # define reset_stdin() |
949 #endif | 949 #endif |
950 | 950 |