From 5b778a64ec2e82a7d8d28c3c36698cd42a41c539 Mon Sep 17 00:00:00 2001 From: Stanislav Asunkin <1353637+stasjok@users.noreply.github.com> Date: Sun, 7 Jul 2024 11:37:39 +0300 Subject: [PATCH] fix(health): fix fetching url with python in provider health (#29594) --- runtime/lua/vim/provider/health.lua | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/runtime/lua/vim/provider/health.lua b/runtime/lua/vim/provider/health.lua index 860f839f23..9ff4d15257 100644 --- a/runtime/lua/vim/provider/health.lua +++ b/runtime/lua/vim/provider/health.lua @@ -409,12 +409,15 @@ local function download(url) return out end elseif vim.fn.executable('python') == 1 then - local script = "try:\n\ - from urllib.request import urlopen\n\ - except ImportError:\n\ - from urllib2 import urlopen\n\ - response = urlopen('" .. url .. "')\n\ - print(response.read().decode('utf8'))\n" + local script = ([[ +try: + from urllib.request import urlopen +except ImportError: + from urllib2 import urlopen + +response = urlopen('%s') +print(response.read().decode('utf8')) +]]):format(url) local out, rc = system({ 'python', '-c', script }) if out == '' and rc ~= 0 then return 'python urllib.request error: ' .. rc