From 23a8967ecbeabf656440528d520517a7491de738 Mon Sep 17 00:00:00 2001 From: Fabian Boehm Date: Fri, 12 Jan 2024 18:42:55 +0100 Subject: [PATCH] fish_config: Fix on python < 3.12 if not on Windows --- share/tools/web_config/webconfig.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/share/tools/web_config/webconfig.py b/share/tools/web_config/webconfig.py index 1d8fb3d96..df4f92819 100755 --- a/share/tools/web_config/webconfig.py +++ b/share/tools/web_config/webconfig.py @@ -1674,13 +1674,20 @@ url = "http://localhost:%d/%s/%s" % (PORT, authkey, initial_tab) # Create temporary file to hold redirect to real server. This prevents exposing # the URL containing the authentication key on the command line (see # CVE-2014-2914 or https://github.com/fish-shell/fish-shell/issues/1438). +# + +# If on Windows, the file needs to be closed after writing, otherwise, the browser won't be able to open it." +# unfortunately this was added in python 3.12, so we don't add it on other platforms +# to support older python versions there. +kwargs = {} +if is_windows(): + kwargs["delete_on_close"] = False f = tempfile.NamedTemporaryFile( prefix="web_config", suffix=".html", mode="w", delete=True, - # If on Windows, the file needs to be closed after writing, otherwise, the browser won't be able to open it." - delete_on_close=not is_windows(), + **kwargs, ) f.write(redirect_template_html % (url, url))